Last active
October 9, 2019 04:25
-
-
Save ChoWonmin/be3ff4bfdf6465a5410abee7fd9c0f53 to your computer and use it in GitHub Desktop.
Revisions
-
ChoWonmin revised this gist
Oct 9, 2019 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
ChoWonmin revised this gist
Oct 9, 2019 . 1 changed file with 93 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,93 @@ import { Component, Vue } from 'vue-property-decorator'; import * as THREE from 'three'; import { OrbitControls } from 'three-orbitcontrols-ts'; // @ts-ignore import vs from '!!raw-loader!./Wolf.vert'; // @ts-ignore import fs from '!!raw-loader!./Wolf.frag'; import { Vector3 } from 'three'; @Component({ components: { // }, }) export default class Wolf extends Vue { private camera: any = null; private scene: any = null; private renderer: any = null; private controls: any = null; private material: any = null; private requestAnimationID: number = 0; private width: number = -1; private height: number = -1; private start: number = -1; private init() { const container = document.getElementById('container') as HTMLElement; this.start = Date.now(); this.width = container.clientWidth; this.height = container.clientHeight; this.scene = new THREE.Scene(); this.camera = new THREE.PerspectiveCamera( 70, this.width / this.height, 1, 15000, ); this.camera.position.z = 1000; this.material = new THREE.RawShaderMaterial({ uniforms: { time: { type: 'f', value: 0.0 }, }, vertexShader: vs, fragmentShader: fs, side: THREE.DoubleSide, }); const geometry = new THREE.PlaneBufferGeometry(200, 200); const mesh = new THREE.Mesh(geometry, this.material); this.scene.add(mesh); this.renderer = new THREE.WebGLRenderer({ antialias: true, }); this.renderer.setSize(this.width, this.height); if (container) { container.appendChild(this.renderer.domElement); this.controls = new OrbitControls(this.camera, this.renderer.domElement); } } private animate() { this.requestAnimationID = requestAnimationFrame(this.animate); this.material.uniforms.time.value = 0.00004 * (Date.now() - this.start); this.controls.update(); this.renderer.render(this.scene, this.camera); } private mounted() { this.init(); this.animate(); } private beforeDestroy() { this.scene.dispose(); this.renderer.dispose(); this.renderer.forceContextLoss(); window.cancelAnimationFrame(this.requestAnimationID); // @ts-ignore release force this.renderer.domElement = null; // @ts-ignore release force this.renderer = null; } } -
ChoWonmin revised this gist
Oct 9, 2019 . 3 changed files with 35 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ precision mediump float; uniform float time; varying vec3 vPosition; varying vec2 vUv; void main() { gl_FragColor = vec4( 1.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 charactersOriginal file line number Diff line number Diff line change @@ -1 +0,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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ precision mediump float; uniform mat4 modelMatrix; uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; uniform vec3 cameraPosition; attribute vec2 uv; attribute vec3 position; attribute vec3 normal; varying vec3 vPosition; varying vec2 vUv; void main() { vUv = uv; vPosition = position; gl_Position = projectionMatrix * modelViewMatrix * vec4( vPosition, 1.0 ); } -
ChoWonmin created this gist
Oct 9, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ hello world