This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOT 100% SURE IT'S THE RIGHT WAY TO DO THAT | |
// DECLARE IT AND REUSE IT | |
var vector = new THREE.Vector3() // create temp vec | |
var position = new THREE.Vector3() // create temp vec | |
onMouseMove (evt) { | |
let x = (evt.clientX / window.innerWidth) * 2 - 1 // percentuage and center | |
let y = -(evt.clientY / window.innerHeight) * 2 + 1 | |
vector.set(x, y, 0.5) // create temp vec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function isTouch() { | |
return 'ontouchstart' in document.documentElement | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Vector3 } from 'three' | |
const v = new Vector3() | |
export default (v3, camera) => { | |
v.copy(v3) | |
v.project(camera) | |
return { | |
x: v.x * window.innerWidth * 0.5 + window.innerWidth * 0.5, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const windowSizes = { | |
w: document.body.clientWidth, | |
h: window.innerHeight, | |
} | |
// pixels pos | |
const mousePosPixels = { | |
x: 0, | |
y: 0, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div :class="$style.wrapper"></div> | |
</template> | |
<script> | |
import Vue from 'vue' | |
import Component, { mixins } from 'vue-class-component' | |
@Component({ | |
components: {}, | |
props: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mousePos = { x: 0, y: 0 } | |
export default function (evt) { | |
mousePos.x = (evt.clientX / window.innerWidth) * 2 - 1 | |
mousePos.y = -(evt.clientY / window.innerHeight) * 2 + 1 | |
return mousePos | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mat4 rotationMatrix(vec3 axis, float angle) { | |
axis = normalize(axis); | |
float s = sin(angle); | |
float c = cos(angle); | |
float oc = 1.0 - c; | |
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0, | |
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0, | |
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0, | |
0.0, 0.0, 0.0, 1.0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RN from 'random-number'; | |
let rand = RN.generator(); | |
let randInt = (min, max) => { | |
return rand(min, max, true); | |
}; | |
let randFloat = (min, max) => { | |
return rand(min, max, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MathUtils } from "three"; | |
export default function distance(width, camera) { | |
const vFOV = MathUtils.degToRad(camera.fov); | |
const distance = width / camera.aspect / (2 * Math.tan(vFOV / 2)); | |
const heightPlane = 2 * Math.tan(vFOV / 2) * distance; | |
return { distance, height: heightPlane }; | |
} |
OlderNewer