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 */ | |
| import dat from 'dat.gui'; | |
| class Editor { | |
| get bg() { | |
| return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUAAAAFACAYAAADNkKWqAAALlklEQVR4Ae3XsXGEUBBEQaECg2zIPwoS2DgwMLgiimfQSmBGvZ+pumVmnj9/BAgQ+KDA+v7P571n//qxXfL5e3+RwNe/v//IXSwBAgRyAQOYn0ABAgQqAQNYycslQCAXMID5CRQgQKASMICVvFwCBHIBA5ifQAECBCoBA1jJyyVAIBcwgPkJFCBAoBIwgJW8XAIEcgEDmJ9AAQIEKgEDWMnLJUAgFzCA+QkUIECgEjCAlbxcAgRyAQOYn0ABAgQqAQNYycslQCAXMID5CRQgQKASMICVvFwCBHIBA5ifQAECBCoBA1jJyyVAIBcwgPkJFCBAoBIwgJW8XAIEcgEDmJ9AAQIEKgEDWMnLJUAgFzCA+QkUIECgEjCAlbxcAgRyAQOYn0ABAgQqAQNYycslQCAXMID5CRQgQKASMICVvFwCBHIBA5ifQAECBCqBZWaeKlwuAQIESoH1DT/vPetwbJd8/t5fJPD1789P4OjhiSVAoBcwgP0NNCBAIBIwgBG8WAIEegED2N9AAwIEIgEDGMGLJUCgFzCA/Q00IEAgEjCAEbxYAgR6AQPY30ADAgQiAQMYwYslQKAXMID9DTQgQCASMIARvFgCBHoBA9jfQAMCBCIBAxjBiyVAoBcwgP0NNCBAIBIwgBG8WAIEegED2N9AAwIEIgEDGMGLJUCgFzCA/Q00IEAgEjCAEbxYAgR6AQPY30ADAgQiAQMYwYslQKAXMID9DTQgQCASMIARvFgCBHoBA9jfQAMCBCIBAxjBiyVAoBcwgP0NNCBAIBIwgBG8WAIEegED2N9AAwIEIgEDGMGLJUCgFzCA/Q00IEAgElhm5omyxRIgQCAVWN/0896zEsd2yefv |
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 createSpiral = ({ | |
| radius = 5, | |
| turns = 3, | |
| poinstPerTurn = 20, | |
| from = new THREE.Vector3, | |
| axis = 'xyz', | |
| convertToVectors = true | |
| }) => { | |
| const angleStep = (Math.PI * 2) / poinstPerTurn; | |
| const heightStep = .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
| const delay = (game, delay = 1) => game.add.tween(this) | |
| .to({}, delay, null, true).onComplete; | |
| const makeText = (game, props, anchor = {x: .5, y: .5}) => { | |
| const {value, styles} = props; | |
| const {x, y} = anchor; | |
| const text = game.make.text(0, 0, value, styles); | |
| text.anchor.set(x, y); | |
| return text; | |
| }; |
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 */ | |
| class StateMachine { | |
| constructor(character) { | |
| this._states = {}; | |
| this._currentState = null; | |
| this.character = character; | |
| } | |
| addState(name, state) { |
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 vertexShader = () => ` | |
| varying vec2 vUv; | |
| void main() { | |
| vUv = uv; | |
| gl_Position = vec4( position, 1. ); | |
| } | |
| `; | |
| const fragmentShader = () => ` | |
| varying vec2 vUv; |
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 cloneGltf = (gltf) => { | |
| const clone = { | |
| animations: gltf.animations, | |
| scene: gltf.scene.clone(true) | |
| }; | |
| const skinnedMeshes = {}; | |
| gltf.scene.traverse(node => { | |
| if (node.isSkinnedMesh) { |
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
| class GameStore { | |
| constructor(props, ignoreResetProps = [], isDevelopment = false) { | |
| this._listeners = {}; | |
| this._values = {}; | |
| this._defaultProps = props; | |
| this._ignoreResetProps = ignoreResetProps; | |
| this.isDevelopment = isDevelopment; | |
| if (isDevelopment) { |
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
| /** | |
| * A utility that blurs the render() function by averaging samples over many frames | |
| * @param render | |
| * @param opts | |
| * @returns {Function} | |
| */ | |
| export function createMotionBlur(render, opts = {}) { | |
| const { samplesPerFrame = 4, shutterAngle = 0.5, onlyExporting = false } = opts; | |
| const otherCanvas = document.createElement('canvas'); | |
| const otherContext = otherCanvas.getContext('2d'); |
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 attachObjectToCamera = (object, delta) => { | |
| camera.updateMatrixWorld(); | |
| const target = new THREE.Vector3(0, -.3, -3); | |
| target.applyMatrix4(camera.matrixWorld); | |
| const moveSpeed = 15; | |
| const distance = object.position.distanceTo(target); |
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 defaultProps = { | |
| dist: .15, | |
| time: 10 | |
| } | |
| export const cameraShake = (camera = null, count = 10, callback = () => {}, props = defaultProps) => { | |
| if (!camera) { | |
| throw new Error('Camera is not define!'); | |
| } | |
| const basePosition = new THREE.Vector3().copy(camera.position); |
NewerOlder