This file contains hidden or 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 hidden or 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
| /* eslint-disable no-multi-assign */ | |
| import { useMemo } from 'react' | |
| import { TextureLoader, NearestFilter, FloatType, HalfFloatType, LinearEncoding } from 'three' | |
| import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js' | |
| import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js' | |
| import staticData from './data.yml' | |
| class Resources { |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 }; | |
| } |
This file contains hidden or 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 hidden or 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 hidden or 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"; | |
| // this gives the "visible" plane sizes that is visible from the camera at a certain distance | |
| export default function(distance, camera) { | |
| const vFOV = MathUtils.degToRad(camera.fov); | |
| const height = 2 * Math.tan(vFOV / 2) * distance; | |
| const width = height * camera.aspect; | |
| return { width, height }; | |
| } |