language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
mrdoob
three.js
796539369ef1a808ccd6b250ec2b2a327cf7bd37.json
Simplify regex a bit, update comments.
test/unit/src/animation/PropertyBinding.js
@@ -2,7 +2,7 @@ * @author TristanVALCKE / https://github.com/TristanVALCKE */ -QUnit.module( 'BufferAttribute' ); +QUnit.module( 'PropertyBinding' ); QUnit.test( 'parseTrackName' , function( assert ) {
true
Other
mrdoob
three.js
eb71b74d47cd3d6605d1069d38f708aa01e80735.json
Set camera to 0,0,0 in webvr_shadow.
examples/webvr_shadow.html
@@ -43,18 +43,14 @@ scene = new THREE.Scene(); - var dummy = new THREE.Camera(); - dummy.position.set( 0, 0.5, 3 ); - dummy.lookAt( new THREE.Vector3( 0, 0.5, 0 ) ); - scene.add( dummy ); - camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.1, 10 ); - dummy.add( camera ); + scene.add( camera ); var geometry = new THREE.TorusKnotGeometry( 0.4, 0.15, 150, 20 ); var material = new THREE.MeshStandardMaterial( { roughness: 0.01, metalness: 0.2 } ); var mesh = new THREE.Mesh( geometry, material ); mesh.position.y = 0.75; + mesh.position.z = - 2; mesh.castShadow = true; mesh.receiveShadow = true; scene.add( mesh ); @@ -63,28 +59,39 @@ var material = new THREE.MeshStandardMaterial( { roughness: 1.0, metalness: 0.0 } ); var mesh = new THREE.Mesh( geometry, material ); mesh.position.y = - 0.2; + mesh.position.z = - 2; mesh.castShadow = true; mesh.receiveShadow = true; scene.add( mesh ); var light = new THREE.DirectionalLight( 0x8800ff ); - light.position.set( - 1, 1.5, 0.5 ); + light.position.set( - 1, 1.5, - 1.5 ); light.castShadow = true; light.shadow.camera.zoom = 4; scene.add( light ); + light.target.position.set( 0, 0, - 2 ); + scene.add( light.target ); + + var helper = new THREE.CameraHelper( light.shadow.camera ); + // scene.add( helper ); var light = new THREE.DirectionalLight( 0xff0000 ); - light.position.set( 1, 1.5, - 0.5 ); + light.position.set( 1, 1.5, - 2.5 ); light.castShadow = true; light.shadow.camera.zoom = 4; scene.add( light ); + light.target.position.set( 0, 0, - 2 ); + scene.add( light.target ); + + var helper = new THREE.CameraHelper( light.shadow.camera ); + // scene.add( helper ); // mirror = new THREE.Mirror( 1.4, 1.4, { textureWidth: window.innerWidth, textureHeight: window.innerHeight } ); mirror.position.x = 1; mirror.position.y = 0.5; - mirror.position.z = -1; + mirror.position.z = -3; mirror.rotation.y = - Math.PI / 4; scene.add( mirror );
false
Other
mrdoob
three.js
bf1efc61c7c48f119c405b1cb3d19f80d0b9f4cf.json
Improve documentation of TextGeometry usage
docs/api/geometries/TextGeometry.html
@@ -12,7 +12,11 @@ <h1>[name]</h1> - <div class="desc">This object creates a 3D object of text as a single object.</div> + <div class="desc"> + A class for generating text as a single geometry. It is constructed by providing a string of text, and a hash of + parameters consisting of a loaded [page:Font] and settings for the geometry's parent [page:ExtrudeGeometry]. + See the [page:Font], [page:FontLoader] and [page:Creating_Text] pages for additional details. + </div> <iframe id="scene" src="scenes/geometry-browser.html#TextGeometry"></iframe> @@ -32,22 +36,40 @@ <h1>[name]</h1> </script> - <h2>Example</h2> + <h2>Examples</h2> <div> [example:webgl_geometry_text geometry / text ]<br/> [example:webgl_geometry_text2 geometry / text2 ] </div> + <code> + var loader = new THREE.FontLoader(); + + loader.load( 'fonts/helvetiker_regular.typeface.json', function ( font ) { + + var geometry = new THREE.TextGeometry( 'Hello three.js!', { + font: font, + size: 80, + height: 5, + curveSegments: 12, + bevelEnabled: true, + bevelThickness: 10, + bevelSize: 8, + bevelSegments: 5 + } ); + } ); + </code> + <h2>Constructor</h2> <h3>[name]([page:String text], [page:Object parameters])</h3> <div> text — The text that needs to be shown. <br /> parameters — Object that can contains the following parameters. <ul> - <li>font — THREE.Font.</li> - <li>size — Float. Size of the text.</li> + <li>font — an instance of THREE.Font.</li> + <li>size — Float. Size of the text. Default is 100.</li> <li>height — Float. Thickness to extrude text. Default is 50.</li> <li>curveSegments — Integer. Number of points on the curves. Default is 12.</li> <li>bevelEnabled — Boolean. Turn on bevel. Default is False.</li>
true
Other
mrdoob
three.js
bf1efc61c7c48f119c405b1cb3d19f80d0b9f4cf.json
Improve documentation of TextGeometry usage
docs/manual/introduction/Creating-text.html
@@ -61,13 +61,19 @@ <h2>3. Create a model in your favourite 3D application and export to three.js</h <h2>4. Procedural Text Geometry</h2> <div> <p> - Use this method if you prefer to work purely in three.js or create procedural and dynamic 3d - text geometries. However, font data files in THREE.js JSON format need to be loaded - before this will work. - See the [page:TextGeometry] page for examples of JSON fonts. + If you prefer to work purely in THREE.js or to create procedural and dynamic 3D + text geometries, you can create a mesh whose geometry is an instance of THREE.TextGeometry: + </p> + <p> + <code>new THREE.TextGeometry( text, parameters );</code> + </p> + <p> + In order for this to work, however, your TextGeomety will need an instance of THREE.Font + to be set on its "font" parameter. + + See the [page:TextGeometry] page for more info on how this can be done, descriptions of each + accepted parameter, and a list of the JSON fonts that come with the THREE.js distribution itself. </p> - <p>A Text Geometry can then be created with </p> - <code>new THREE.TextGeometry( text, parameters );</code> <h3>Examples</h3> [example:webgl_geometry_text WebGL / geometry / text]<br />
true
Other
mrdoob
three.js
2944a3f061ddec5350cc941fe5afe15a0f4b4803.json
add support for Lightimport in VRML for import PointLight and SpotLight. An AmbientLight is emitted when in the name "AmbientLight" occurs. exampel: vrml-Code: DEF Licht_AmbientLight Transform { translation 0 4.274257 0 children [ DEF LIGHT_Licht_AmbientLight PointLight { location 0 0 0 radius 100000000 color 0.34902 0.34902 1 intensity 0.23 on TRUE } ] } DEF Licht_1spot Transform { translation -56.342838 57.6591 -58.975361 rotation -0.244504 0.769274 0.590284 -0.987861 children [ DEF LIGHT_Licht_1spot SpotLight { location 0 0 0 direction 1 0 0 cutOffAngle 0.587197 radius 100000000 color 0.47451 0.823529 1 intensity 1 on TRUE } ] } DEF Licht Transform { translation -49.414658 88.717239 51.611542 children [ DEF LIGHT_Licht PointLight { location 0 0 0 radius 100000000 color 1 0.807843 0.560784 intensity 1 on TRUE } ] }
examples/js/loaders/VRMLLoader.js
@@ -415,7 +415,9 @@ THREE.VRMLLoader.prototype = { }; break; - + ++ case 'location': ++ case 'direction': case 'translation': case 'scale': case 'size': @@ -434,6 +436,8 @@ THREE.VRMLLoader.prototype = { break; + case 'intensity': + case 'cutOffAngle': case 'radius': case 'topRadius': case 'bottomRadius': @@ -468,7 +472,8 @@ THREE.VRMLLoader.prototype = { }; break; - + + case 'on': case 'ccw': case 'solid': case 'colorPerVertex': @@ -623,6 +628,85 @@ THREE.VRMLLoader.prototype = { var object = parent; + if(data.string.indexOf("AmbientLight")>-1 && data.nodeType=='PointLight'){ + //wenn im Namen "AmbientLight" vorkommt und es ein PointLight ist, + //diesen Typ in 'AmbientLight' ändern + data.nodeType='AmbientLight'; + } + + l_visible=data.on; + if(l_visible==undefined)l_visible=true; + l_intensity=data.intensity; + if(l_intensity==undefined)l_intensity=true; + if(data.color!=undefined) + l_color= new THREE.Color(data.color.r, data.color.g,data.color.b ); + else + l_color= new THREE.Color(0, 0,0); + + + + if('AmbientLight' === data.nodeType){ + object=new THREE.AmbientLight( + l_color.getHex(), + l_intensity + ); + object.visible=l_visible; + + parent.add( object ); + + } + else + if('PointLight' === data.nodeType){ + l_distance =0; //0="unendlich" ...1000 + l_decay=0; //-1.. ? + + if(data.radius!=undefined && data.radius<1000){ + //l_radius=data.radius; + l_distance=data.radius; + l_decay=1; + } + object=new THREE.PointLight( + l_color.getHex(), + l_intensity, + l_distance); + object.visible=l_visible; + + parent.add( object ); + } + else + if('SpotLight' === data.nodeType){ + l_intensity=1; + l_distance =0;//0="unendlich"=1000 + l_angle=Math.PI/3; + l_penumbra=0.0;//0..1 + l_decay=0;//-1.. ? + l_visible=true; + + if(data.radius!=undefined && data.radius<1000){ + //l_radius=data.radius; + l_distance=data.radius; + l_decay=1; + } + if(data.cutOffAngle!=undefined)l_angle=data.cutOffAngle; + + object = new THREE.SpotLight( + l_color.getHex(), + l_intensity, + l_distance, + l_angle, + l_penumbra, + l_decay + ); + object.visible=l_visible; + parent.add( object ); + /* + var lightHelper = new THREE.SpotLightHelper( object ); + parent.parent.add( lightHelper ); + lightHelper.update(); + */ + } + else + if ( 'Transform' === data.nodeType || 'Group' === data.nodeType ) { object = new THREE.Object3D();
false
Other
mrdoob
three.js
15544dface5b05cc7ec14f39e211b5fcbda17d24.json
Add missing Toon Material and shader files
src/materials/MeshToonMaterial.js
@@ -0,0 +1,171 @@ +import { Material } from './Material'; +import { MultiplyOperation } from '../constants'; +import { Vector2 } from '../math/Vector2'; +import { Color } from '../math/Color'; + +/** + * @author takahirox / http://github.com/takahirox + * + * parameters = { + * color: <hex>, + * specular: <hex>, + * shininess: <float>, + * opacity: <float>, + * + * map: new THREE.Texture( <Image> ), + * + * lightMap: new THREE.Texture( <Image> ), + * lightMapIntensity: <float> + * + * aoMap: new THREE.Texture( <Image> ), + * aoMapIntensity: <float> + * + * emissive: <hex>, + * emissiveIntensity: <float> + * emissiveMap: new THREE.Texture( <Image> ), + * + * bumpMap: new THREE.Texture( <Image> ), + * bumpScale: <float>, + * + * normalMap: new THREE.Texture( <Image> ), + * normalScale: <Vector2>, + * + * displacementMap: new THREE.Texture( <Image> ), + * displacementScale: <float>, + * displacementBias: <float>, + * + * specularMap: new THREE.Texture( <Image> ), + * + * alphaMap: new THREE.Texture( <Image> ), + * + * envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ), + * combine: THREE.Multiply, + * reflectivity: <float>, + * refractionRatio: <float>, + * + * gradientMap: new THREE.Texture( <Image> ), + * + * wireframe: <boolean>, + * wireframeLinewidth: <float>, + * + * skinning: <bool>, + * morphTargets: <bool>, + * morphNormals: <bool> + * } + */ + +function MeshToonMaterial( parameters ) { + + Material.call( this ); + + this.type = 'MeshToonMaterial'; + + this.color = new Color( 0xffffff ); // diffuse + this.specular = new Color( 0x111111 ); + this.shininess = 30; + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.emissive = new Color( 0x000000 ); + this.emissiveIntensity = 1.0; + this.emissiveMap = null; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalScale = new Vector2( 1, 1 ); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.specularMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.combine = MultiplyOperation; + this.reflectivity = 1; + this.refractionRatio = 0.98; + + this.gradientMap = null; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.skinning = false; + this.morphTargets = false; + this.morphNormals = false; + + this.setValues( parameters ); + +} + +MeshToonMaterial.prototype = Object.create( Material.prototype ); +MeshToonMaterial.prototype.constructor = MeshToonMaterial; + +MeshToonMaterial.prototype.isMeshToonMaterial = true; + +MeshToonMaterial.prototype.copy = function ( source ) { + + Material.prototype.copy.call( this, source ); + + this.color.copy( source.color ); + this.specular.copy( source.specular ); + this.shininess = source.shininess; + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.emissive.copy( source.emissive ); + this.emissiveMap = source.emissiveMap; + this.emissiveIntensity = source.emissiveIntensity; + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalScale.copy( source.normalScale ); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.specularMap = source.specularMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.combine = source.combine; + this.reflectivity = source.reflectivity; + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + this.skinning = source.skinning; + this.morphTargets = source.morphTargets; + this.morphNormals = source.morphNormals; + + return this; + +}; + + +export { MeshToonMaterial };
true
Other
mrdoob
three.js
15544dface5b05cc7ec14f39e211b5fcbda17d24.json
Add missing Toon Material and shader files
src/renderers/shaders/ShaderLib/meshtoon_frag.glsl
@@ -0,0 +1,68 @@ +#define TOON + +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; + +#include <common> +#include <packing> +#include <color_pars_fragment> +#include <uv_pars_fragment> +#include <uv2_pars_fragment> +#include <map_pars_fragment> +#include <alphamap_pars_fragment> +#include <aomap_pars_fragment> +#include <lightmap_pars_fragment> +#include <emissivemap_pars_fragment> +#include <envmap_pars_fragment> +#include <gradientmap_pars_fragment> +#include <fog_pars_fragment> +#include <bsdfs> +#include <lights_pars> +#include <lights_phong_pars_fragment> +#include <shadowmap_pars_fragment> +#include <bumpmap_pars_fragment> +#include <normalmap_pars_fragment> +#include <specularmap_pars_fragment> +#include <logdepthbuf_pars_fragment> +#include <clipping_planes_pars_fragment> + +void main() { + + #include <clipping_planes_fragment> + + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + + #include <logdepthbuf_fragment> + #include <map_fragment> + #include <color_fragment> + #include <alphamap_fragment> + #include <alphatest_fragment> + #include <specularmap_fragment> + #include <normal_flip> + #include <normal_fragment> + #include <emissivemap_fragment> + + // accumulation + #include <lights_phong_fragment> + #include <lights_template> + + // modulation + #include <aomap_fragment> + + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + + #include <envmap_fragment> + + gl_FragColor = vec4( outgoingLight, diffuseColor.a ); + + #include <premultiplied_alpha_fragment> + #include <tonemapping_fragment> + #include <encodings_fragment> + #include <fog_fragment> + +}
true
Other
mrdoob
three.js
15544dface5b05cc7ec14f39e211b5fcbda17d24.json
Add missing Toon Material and shader files
src/renderers/shaders/ShaderLib/meshtoon_vert.glsl
@@ -0,0 +1,55 @@ +#define TOON + +varying vec3 vViewPosition; + +#ifndef FLAT_SHADED + + varying vec3 vNormal; + +#endif + +#include <common> +#include <uv_pars_vertex> +#include <uv2_pars_vertex> +#include <displacementmap_pars_vertex> +#include <envmap_pars_vertex> +#include <color_pars_vertex> +#include <morphtarget_pars_vertex> +#include <skinning_pars_vertex> +#include <shadowmap_pars_vertex> +#include <logdepthbuf_pars_vertex> +#include <clipping_planes_pars_vertex> + +void main() { + + #include <uv_vertex> + #include <uv2_vertex> + #include <color_vertex> + + #include <beginnormal_vertex> + #include <morphnormal_vertex> + #include <skinbase_vertex> + #include <skinnormal_vertex> + #include <defaultnormal_vertex> + +#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED + + vNormal = normalize( transformedNormal ); + +#endif + + #include <begin_vertex> + #include <displacementmap_vertex> + #include <morphtarget_vertex> + #include <skinning_vertex> + #include <project_vertex> + #include <logdepthbuf_vertex> + #include <clipping_planes_vertex> + + vViewPosition = - mvPosition.xyz; + + #include <worldpos_vertex> + #include <envmap_vertex> + #include <shadowmap_vertex> + +}
true
Other
mrdoob
three.js
0c5e84eac5d07aec1de6ae5f0f4286a7dd7f68ee.json
Update shared MMDPhysics
examples/js/animation/MMDPhysics.js
@@ -131,6 +131,14 @@ THREE.MMDPhysics.prototype = { update: function ( delta ) { + this.updateRigidBodies(); + this.stepSimulation( delta ); + this.updateBones(); + + }, + + stepSimulation: function ( delta ) { + var unitStep = this.unitStep; var stepTime = delta; var maxStepNum = ( ( delta / unitStep ) | 0 ) + 1; @@ -148,9 +156,7 @@ THREE.MMDPhysics.prototype = { } - this.updateRigidBodies(); this.world.stepSimulation( stepTime, maxStepNum, unitStep ); - this.updateBones(); },
true
Other
mrdoob
three.js
0c5e84eac5d07aec1de6ae5f0f4286a7dd7f68ee.json
Update shared MMDPhysics
examples/js/loaders/MMDLoader.js
@@ -2223,6 +2223,9 @@ THREE.MMDHelper = function ( renderer ) { this.doOutlineDrawing = true; this.doCameraAnimation = true; + this.sharedPhysics = false; + this.masterPhysics = null; + this.audioManager = null; this.camera = null; @@ -2296,31 +2299,31 @@ THREE.MMDHelper.prototype = { setPhysicses: function ( params ) { - params = ( params === undefined ) ? {} : Object.assign( {}, params ); - for ( var i = 0; i < this.meshes.length; i++ ) { this.setPhysics( this.meshes[ i ], params ); - if ( i === 0 && params.sharePhysicsWorld === true ) { - - params.world = this.meshes[ 0 ].physics.world; - - } - } }, setPhysics: function ( mesh, params ) { - if ( params === undefined ) params = {}; + params = ( params === undefined ) ? {} : Object.assign( {}, params ); + + if ( params.world === undefined && this.sharedPhysics ) { + + var masterPhysics = this.getMasterPhysics(); + + if ( masterPhysics !== null ) params.world = masterPhysics.world; + + } var warmup = params.warmup !== undefined ? params.warmup : 60; var physics = new THREE.MMDPhysics( mesh, params ); - if ( mesh.mixer !== null && mesh.mixer !== undefined && this.doAnimation === true && params.preventAnimationWarmup !== false ) { + if ( mesh.mixer !== null && mesh.mixer !== undefined && params.preventAnimationWarmup !== false ) { this.animateOneMesh( 0, mesh ); physics.reset(); @@ -2335,6 +2338,26 @@ THREE.MMDHelper.prototype = { }, + getMasterPhysics: function () { + + if ( this.masterPhysics !== null ) return this.masterPhysics; + + for ( var i = 0, il = this.meshes.length; i < il; i ++ ) { + + var physics = this.meshes[ i ].physics; + + if ( physics !== undefined && physics !== null ) { + + this.masterPhysics = physics; + return this.masterPhysics; + + } + } + + return null; + + }, + enablePhysics: function ( enabled ) { if ( enabled === true ) { @@ -2597,6 +2620,8 @@ THREE.MMDHelper.prototype = { } + if ( this.sharedPhysics ) this.updateSharedPhysics( delta ); + this.animateCamera( delta ); }, @@ -2640,14 +2665,50 @@ THREE.MMDHelper.prototype = { } - if ( physics !== null && this.doPhysics === true ) { + if ( physics !== null && this.doPhysics && ! this.sharedPhysics) { physics.update( delta ); } }, + updateSharedPhysics: function ( delta ) { + + if ( this.meshes.length === 0 || ! this.doPhysics || ! this.sharedPhysics ) return; + + var physics = this.getMasterPhysics(); + + if ( physics === null ) return; + + for ( var i = 0, il = this.meshes.length; i < il; i ++ ) { + + var p = this.meshes[ i ].physics; + + if ( p !== null && p !== undefined ) { + + p.updateRigidBodies(); + + } + + } + + physics.stepSimulation( delta ); + + for ( var i = 0, il = this.meshes.length; i < il; i ++ ) { + + var p = this.meshes[ i ].physics; + + if ( p !== null && p !== undefined ) { + + p.updateBones(); + + } + + } + + }, + animateCamera: function ( delta ) { if ( this.camera === null ) {
true
Other
mrdoob
three.js
0c82ecf8a5b7878ac0dff9e94c621692315d1b6f.json
Remove side effect of MMDLoader.loadVmds()
examples/js/loaders/MMDLoader.js
@@ -123,6 +123,7 @@ THREE.MMDLoader.prototype.loadVmds = function ( urls, callback, onProgress, onEr var scope = this; var vmds = []; + urls = urls.slice(); function run () {
false
Other
mrdoob
three.js
f1db204e2d7ebdec7db6cc4b4e8ae7d9d6562c75.json
remove obsolete uniform type properties
examples/js/renderers/WebGLDeferredRenderer.js
@@ -1623,13 +1623,13 @@ THREE.ShaderDeferred = { uniforms: { - map: { type: "t", value: null }, - offsetRepeat: { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) }, + map: { value: null }, + offsetRepeat: { value: new THREE.Vector4( 0, 0, 1, 1 ) }, - diffuse: { type: "c", value: new THREE.Color( 0x000000 ) }, - emissive: { type: "c", value: new THREE.Color( 0x000000 ) }, - specular: { type: "c", value: new THREE.Color( 0x000000 ) }, - shininess: { type: "f", value: 30.0 } + diffuse: { value: new THREE.Color( 0x000000 ) }, + emissive: { value: new THREE.Color( 0x000000 ) }, + specular: { value: new THREE.Color( 0x000000 ) }, + shininess: { value: 30.0 } }, @@ -1687,9 +1687,9 @@ THREE.ShaderDeferred = { uniforms: { - samplerColor: { type: "t", value: null }, - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 } + samplerColor: { value: null }, + viewWidth: { value: 800 }, + viewHeight: { value: 600 } }, @@ -1729,18 +1729,18 @@ THREE.ShaderDeferred = { uniforms: { - samplerNormalDepth: { type: "t", value: null }, - samplerColor: { type: "t", value: null }, + samplerNormalDepth: { value: null }, + samplerColor: { value: null }, - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + matProjInverse: { value: new THREE.Matrix4() }, - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + viewWidth: { value: 800 }, + viewHeight: { value: 600 }, - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightPositionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightIntensity: { type: "f", value: 1.0 }, - lightRadius: { type: "f", value: 1.0 } + lightColor: { value: new THREE.Color( 0x000000 ) }, + lightPositionVS: { value: new THREE.Vector3( 0, 1, 0 ) }, + lightIntensity: { value: 1.0 }, + lightRadius: { value: 1.0 } }, @@ -1811,19 +1811,19 @@ THREE.ShaderDeferred = { uniforms: { - samplerNormalDepth: { type: "t", value: null }, - samplerColor: { type: "t", value: null }, + samplerNormalDepth: { value: null }, + samplerColor: { value: null }, - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + matProjInverse: { value: new THREE.Matrix4() }, - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + viewWidth: { value: 800 }, + viewHeight: { value: 600 }, - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightDirectionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightPositionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightAngle: { type: "f", value: 1.0 }, - lightIntensity: { type: "f", value: 1.0 } + lightColor: { value: new THREE.Color( 0x000000 ) }, + lightDirectionVS: { value: new THREE.Vector3( 0, 1, 0 ) }, + lightPositionVS: { value: new THREE.Vector3( 0, 1, 0 ) }, + lightAngle: { value: 1.0 }, + lightIntensity: { value: 1.0 } }, @@ -1907,17 +1907,17 @@ THREE.ShaderDeferred = { uniforms: { - samplerNormalDepth: { type: "t", value: null }, - samplerColor: { type: "t", value: null }, + samplerNormalDepth: { value: null }, + samplerColor: { value: null }, - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + matProjInverse: { value: new THREE.Matrix4() }, - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + viewWidth: { value: 800 }, + viewHeight: { value: 600 }, - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightDirectionVS : { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightIntensity: { type: "f", value: 1.0 } + lightColor: { value: new THREE.Color( 0x000000 ) }, + lightDirectionVS : { value: new THREE.Vector3( 0, 1, 0 ) }, + lightIntensity: { value: 1.0 } }, @@ -1972,7 +1972,7 @@ THREE.ShaderDeferred = { uniforms: { - shininess: { type: "f", value: 30.0 } + shininess: { value: 30.0 } }, @@ -2030,17 +2030,17 @@ THREE.ShaderDeferred = { uniforms: { - samplerNormalDepthShininess: { type: "t", value: null }, + samplerNormalDepthShininess: { value: null }, - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + matProjInverse: { value: new THREE.Matrix4() }, - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + viewWidth: { value: 800 }, + viewHeight: { value: 600 }, - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightPositionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightIntensity: { type: "f", value: 1.0 }, - lightRadius: { type: "f", value: 1.0 } + lightColor: { value: new THREE.Color( 0x000000 ) }, + lightPositionVS: { value: new THREE.Vector3( 0, 1, 0 ) }, + lightIntensity: { value: 1.0 }, + lightRadius: { value: 1.0 } }, @@ -2101,18 +2101,18 @@ THREE.ShaderDeferred = { uniforms: { - samplerNormalDepthShininess: { type: "t", value: null }, + samplerNormalDepthShininess: { value: null }, - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + matProjInverse: { value: new THREE.Matrix4() }, - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + viewWidth: { value: 800 }, + viewHeight: { value: 600 }, - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightDirectionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightPositionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightAngle: { type: "f", value: 1.0 }, - lightIntensity: { type: "f", value: 1.0 } + lightColor: { value: new THREE.Color( 0x000000 ) }, + lightDirectionVS: { value: new THREE.Vector3( 0, 1, 0 ) }, + lightPositionVS: { value: new THREE.Vector3( 0, 1, 0 ) }, + lightAngle: { value: 1.0 }, + lightIntensity: { value: 1.0 } }, @@ -2194,16 +2194,16 @@ THREE.ShaderDeferred = { uniforms: { - samplerNormalDepthShininess: { type: "t", value: null }, + samplerNormalDepthShininess: { value: null }, - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + matProjInverse: { value: new THREE.Matrix4() }, - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + viewWidth: { value: 800 }, + viewHeight: { value: 600 }, - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightDirectionVS : { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightIntensity: { type: "f", value: 1.0 } + lightColor: { value: new THREE.Color( 0x000000 ) }, + lightDirectionVS : { value: new THREE.Vector3( 0, 1, 0 ) }, + lightIntensity: { value: 1.0 } }, @@ -2258,18 +2258,18 @@ THREE.ShaderDeferred = { uniforms: { - samplerLight: { type: "t", value: null }, + samplerLight: { value: null }, - map: { type: "t", value: null }, - offsetRepeat: { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) }, + map: { value: null }, + offsetRepeat: { value: new THREE.Vector4( 0, 0, 1, 1 ) }, - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + viewWidth: { value: 800 }, + viewHeight: { value: 600 }, - diffuse: { type: "c", value: new THREE.Color( 0x000000 ) }, - emissive: { type: "c", value: new THREE.Color( 0x000000 ) }, - specular: { type: "c", value: new THREE.Color( 0x000000 ) }, - shininess: { type: "f", value: 30.0 } + diffuse: { value: new THREE.Color( 0x000000 ) }, + emissive: { value: new THREE.Color( 0x000000 ) }, + specular: { value: new THREE.Color( 0x000000 ) }, + shininess: { value: 30.0 } }, @@ -2341,7 +2341,7 @@ THREE.ShaderDeferred = { uniforms: { - samplerResult: { type: "t", value: null } + samplerResult: { value: null } },
false
Other
mrdoob
three.js
61efe3aad888d3c17ee761664ca7edfa59af5f18.json
update outdated devdependencies
package.json
@@ -51,8 +51,8 @@ "eslint": "^3.10.1", "eslint-config-mdcs": "^4.2.2", "qunitjs": "^2.1.1", - "rollup": "^0.36.3", - "rollup-watch": "^2.5.0", + "rollup": "^0.41.4", + "rollup-watch": "^3.2.2", "uglify-js": "^2.6.0" } }
false
Other
mrdoob
three.js
df1be793fd36a31b94931265d7c756a274985a94.json
Add Normals + groups
src/geometries/ExtrudeGeometry.js
@@ -69,7 +69,7 @@ function ExtrudeBufferGeometry( shapes, options ) { this.addShapeList( shapes, options ); - this.computeFaceNormals(); + this.computeVertexNormals(); // can't really use automatic vertex normals // as then front and back sides get smoothed too @@ -567,6 +567,8 @@ ExtrudeBufferGeometry.prototype.addShape = function ( shape, options ) { ///// Internal functions function buildLidFaces() { + + var start = verticesArray.length/3; if ( bevelEnabled ) { @@ -615,13 +617,16 @@ ExtrudeBufferGeometry.prototype.addShape = function ( shape, options ) { } } + + scope.addGroup( start, verticesArray.length/3 -start, 0); } // Create faces for the z-sides of the shape function buildSideFaces() { + var start = verticesArray.length/3; var layeroffset = 0; sidewalls( contour, layeroffset ); layeroffset += contour.length; @@ -635,6 +640,8 @@ ExtrudeBufferGeometry.prototype.addShape = function ( shape, options ) { layeroffset += ahole.length; } + + scope.addGroup( start, verticesArray.length/3 -start, 1); }
false
Other
mrdoob
three.js
c720cc8c0bcd94d5e989474d637bedc4d3bc2c11.json
Change extrudegeometry to buffergeometry
src/geometries/ExtrudeGeometry.js
@@ -1,4 +1,6 @@ -import { Geometry } from '../core/Geometry'; +//import { Geometry } from '../core/Geometry'; +import { BufferGeometry } from '../core/BufferGeometry'; +import { Float32BufferAttribute } from '../core/BufferAttribute'; import { Vector2 } from '../math/Vector2'; import { Face3 } from '../core/Face3'; import { Vector3 } from '../math/Vector3'; @@ -30,20 +32,20 @@ import { ShapeUtils } from '../extras/ShapeUtils'; function ExtrudeGeometry( shapes, options ) { - if ( typeof( shapes ) === "undefined" ) { + if ( typeof(shapes) === "undefined") { shapes = []; return; } - Geometry.call( this ); + BufferGeometry.call(this); this.type = 'ExtrudeGeometry'; - shapes = Array.isArray( shapes ) ? shapes : [ shapes ]; + shapes = Array.isArray(shapes) ? shapes : [shapes]; - this.addShapeList( shapes, options ); + this.addShapeList(shapes, options); this.computeFaceNormals(); @@ -57,23 +59,83 @@ function ExtrudeGeometry( shapes, options ) { } -ExtrudeGeometry.prototype = Object.create( Geometry.prototype ); +ExtrudeGeometry.prototype = Object.create(BufferGeometry.prototype); ExtrudeGeometry.prototype.constructor = ExtrudeGeometry; -ExtrudeGeometry.prototype.addShapeList = function ( shapes, options ) { +ExtrudeGeometry.prototype.getArrays = function() { + + var verticesArray; + var positionAttribute = this.getAttribute("position"); + if (positionAttribute) { + + verticesArray = Array.prototype.slice.call(positionAttribute.array); + + } else { + + verticesArray = []; + + } + + var uvArray; + var uvAttribute = this.getAttribute("uv"); + if (positionAttribute) { + + uvArray = Array.prototype.slice.call(uvAttribute.array); + + } else { + + uvArray = []; + + } + + var indicesArray; + var IndexAttribute = this.index; + + if (IndexAttribute) { + + indicesArray = Array.prototype.slice.call(IndexAttribute.array); + + } else { + + indicesArray = []; + + } + + return { + position: verticesArray, + uv:uvArray, + index: indicesArray + }; + +}; + +ExtrudeGeometry.prototype.addShapeList = function(shapes, options) { var sl = shapes.length; + options.arrays = this.getArrays() - for ( var s = 0; s < sl; s ++ ) { + for (var s = 0; s < sl; s++) { - var shape = shapes[ s ]; - this.addShape( shape, options ); + var shape = shapes[s]; + this.addShape(shape, options); } + + this.setIndex(options.arrays.index); + this.addAttribute('position', new Float32BufferAttribute(options.arrays.position, 3)); + this.addAttribute('uv', new Float32BufferAttribute(options.arrays.uv, 2)); }; -ExtrudeGeometry.prototype.addShape = function ( shape, options ) { +ExtrudeGeometry.prototype.addShape = function(shape, options) { + + var arrays = options.arrays ? options.arrays : this.getArrays(); + var verticesArray = arrays.position; + var indicesArray = arrays.index; + var uvArray = arrays.uv; + + var placeholder = []; + var amount = options.amount !== undefined ? options.amount : 100; @@ -94,9 +156,9 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { var uvgen = options.UVGenerator !== undefined ? options.UVGenerator : ExtrudeGeometry.WorldUVGenerator; var splineTube, binormal, normal, position2; - if ( extrudePath ) { + if (extrudePath) { - extrudePts = extrudePath.getSpacedPoints( steps ); + extrudePts = extrudePath.getSpacedPoints(steps); extrudeByPath = true; bevelEnabled = false; // bevels not supported for path extrusion @@ -105,7 +167,7 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // TODO1 - have a .isClosed in spline? - splineTube = options.frames !== undefined ? options.frames : extrudePath.computeFrenetFrames( steps, false ); + splineTube = options.frames !== undefined ? options.frames : extrudePath.computeFrenetFrames(steps, false); // console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length); @@ -117,7 +179,7 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // Safeguards if bevels are not enabled - if ( ! bevelEnabled ) { + if (!bevelEnabled) { bevelSegments = 0; bevelThickness = 0; @@ -130,28 +192,28 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { var ahole, h, hl; // looping of holes var scope = this; - var shapesOffset = this.vertices.length; + var shapesOffset = verticesArray.length / 3; - var shapePoints = shape.extractPoints( curveSegments ); + var shapePoints = shape.extractPoints(curveSegments); var vertices = shapePoints.shape; var holes = shapePoints.holes; - var reverse = ! ShapeUtils.isClockWise( vertices ); + var reverse = !ShapeUtils.isClockWise(vertices); - if ( reverse ) { + if (reverse) { vertices = vertices.reverse(); // Maybe we should also check if holes are in the opposite direction, just to be safe ... - for ( h = 0, hl = holes.length; h < hl; h ++ ) { + for (h = 0, hl = holes.length; h < hl; h++) { - ahole = holes[ h ]; + ahole = holes[h]; - if ( ShapeUtils.isClockWise( ahole ) ) { + if (ShapeUtils.isClockWise(ahole)) { - holes[ h ] = ahole.reverse(); + holes[h] = ahole.reverse(); } @@ -162,26 +224,26 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { } - var faces = ShapeUtils.triangulateShape( vertices, holes ); + var faces = ShapeUtils.triangulateShape(vertices, holes); /* Vertices */ var contour = vertices; // vertices has all points but contour has only points of circumference - for ( h = 0, hl = holes.length; h < hl; h ++ ) { + for (h = 0, hl = holes.length; h < hl; h++) { - ahole = holes[ h ]; + ahole = holes[h]; - vertices = vertices.concat( ahole ); + vertices = vertices.concat(ahole); } - function scalePt2( pt, vec, size ) { + function scalePt2(pt, vec, size) { - if ( ! vec ) console.error( "THREE.ExtrudeGeometry: vec does not exist" ); + if (!vec) console.error("THREE.ExtrudeGeometry: vec does not exist"); - return vec.clone().multiplyScalar( size ).add( pt ); + return vec.clone().multiplyScalar(size).add(pt); } @@ -193,7 +255,7 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // Find directions for point movement - function getBevelVec( inPt, inPrev, inNext ) { + function getBevelVec(inPt, inPrev, inNext) { // computes for inPt the corresponding point inPt' on a new contour // shifted by 1 unit (length of normalized vector) to the left @@ -202,86 +264,92 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // inPt' is the intersection of the two lines parallel to the two // adjacent edges of inPt at a distance of 1 unit on the left side. - var v_trans_x, v_trans_y, shrink_by = 1; // resulting translation vector for inPt + var v_trans_x, v_trans_y, shrink_by = 1; // resulting translation vector for inPt // good reading for geometry algorithms (here: line-line intersection) // http://geomalgorithms.com/a05-_intersect-1.html - var v_prev_x = inPt.x - inPrev.x, v_prev_y = inPt.y - inPrev.y; - var v_next_x = inNext.x - inPt.x, v_next_y = inNext.y - inPt.y; + var v_prev_x = inPt.x - inPrev.x, + v_prev_y = inPt.y - inPrev.y; + var v_next_x = inNext.x - inPt.x, + v_next_y = inNext.y - inPt.y; - var v_prev_lensq = ( v_prev_x * v_prev_x + v_prev_y * v_prev_y ); + var v_prev_lensq = (v_prev_x * v_prev_x + v_prev_y * v_prev_y); // check for collinear edges - var collinear0 = ( v_prev_x * v_next_y - v_prev_y * v_next_x ); + var collinear0 = (v_prev_x * v_next_y - v_prev_y * v_next_x); - if ( Math.abs( collinear0 ) > Number.EPSILON ) { + if (Math.abs(collinear0) > Number.EPSILON) { // not collinear // length of vectors for normalizing - var v_prev_len = Math.sqrt( v_prev_lensq ); - var v_next_len = Math.sqrt( v_next_x * v_next_x + v_next_y * v_next_y ); + var v_prev_len = Math.sqrt(v_prev_lensq); + var v_next_len = Math.sqrt(v_next_x * v_next_x + v_next_y * v_next_y); // shift adjacent points by unit vectors to the left - var ptPrevShift_x = ( inPrev.x - v_prev_y / v_prev_len ); - var ptPrevShift_y = ( inPrev.y + v_prev_x / v_prev_len ); + var ptPrevShift_x = (inPrev.x - v_prev_y / v_prev_len); + var ptPrevShift_y = (inPrev.y + v_prev_x / v_prev_len); - var ptNextShift_x = ( inNext.x - v_next_y / v_next_len ); - var ptNextShift_y = ( inNext.y + v_next_x / v_next_len ); + var ptNextShift_x = (inNext.x - v_next_y / v_next_len); + var ptNextShift_y = (inNext.y + v_next_x / v_next_len); // scaling factor for v_prev to intersection point - var sf = ( ( ptNextShift_x - ptPrevShift_x ) * v_next_y - - ( ptNextShift_y - ptPrevShift_y ) * v_next_x ) / - ( v_prev_x * v_next_y - v_prev_y * v_next_x ); + var sf = ((ptNextShift_x - ptPrevShift_x) * v_next_y - + (ptNextShift_y - ptPrevShift_y) * v_next_x) / + (v_prev_x * v_next_y - v_prev_y * v_next_x); // vector from inPt to intersection point - v_trans_x = ( ptPrevShift_x + v_prev_x * sf - inPt.x ); - v_trans_y = ( ptPrevShift_y + v_prev_y * sf - inPt.y ); + v_trans_x = (ptPrevShift_x + v_prev_x * sf - inPt.x); + v_trans_y = (ptPrevShift_y + v_prev_y * sf - inPt.y); // Don't normalize!, otherwise sharp corners become ugly // but prevent crazy spikes - var v_trans_lensq = ( v_trans_x * v_trans_x + v_trans_y * v_trans_y ); - if ( v_trans_lensq <= 2 ) { + var v_trans_lensq = (v_trans_x * v_trans_x + v_trans_y * v_trans_y); + if (v_trans_lensq <= 2) { - return new Vector2( v_trans_x, v_trans_y ); + return new Vector2(v_trans_x, v_trans_y); - } else { + } + else { - shrink_by = Math.sqrt( v_trans_lensq / 2 ); + shrink_by = Math.sqrt(v_trans_lensq / 2); } - } else { + } + else { // handle special case of collinear edges - var direction_eq = false; // assumes: opposite - if ( v_prev_x > Number.EPSILON ) { + var direction_eq = false; // assumes: opposite + if (v_prev_x > Number.EPSILON) { - if ( v_next_x > Number.EPSILON ) { + if (v_next_x > Number.EPSILON) { direction_eq = true; } - } else { + } + else { - if ( v_prev_x < - Number.EPSILON ) { + if (v_prev_x < -Number.EPSILON) { - if ( v_next_x < - Number.EPSILON ) { + if (v_next_x < -Number.EPSILON) { direction_eq = true; } - } else { + } + else { - if ( Math.sign( v_prev_y ) === Math.sign( v_next_y ) ) { + if (Math.sign(v_prev_y) === Math.sign(v_next_y)) { direction_eq = true; @@ -291,99 +359,101 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { } - if ( direction_eq ) { + if (direction_eq) { // console.log("Warning: lines are a straight sequence"); - v_trans_x = - v_prev_y; - v_trans_y = v_prev_x; - shrink_by = Math.sqrt( v_prev_lensq ); + v_trans_x = -v_prev_y; + v_trans_y = v_prev_x; + shrink_by = Math.sqrt(v_prev_lensq); - } else { + } + else { // console.log("Warning: lines are a straight spike"); v_trans_x = v_prev_x; v_trans_y = v_prev_y; - shrink_by = Math.sqrt( v_prev_lensq / 2 ); + shrink_by = Math.sqrt(v_prev_lensq / 2); } } - return new Vector2( v_trans_x / shrink_by, v_trans_y / shrink_by ); + return new Vector2(v_trans_x / shrink_by, v_trans_y / shrink_by); } var contourMovements = []; - for ( var i = 0, il = contour.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) { + for (var i = 0, il = contour.length, j = il - 1, k = i + 1; i < il; i++, j++, k++) { - if ( j === il ) j = 0; - if ( k === il ) k = 0; + if (j === il) j = 0; + if (k === il) k = 0; // (j)---(i)---(k) // console.log('i,j,k', i, j , k) - contourMovements[ i ] = getBevelVec( contour[ i ], contour[ j ], contour[ k ] ); + contourMovements[i] = getBevelVec(contour[i], contour[j], contour[k]); } - var holesMovements = [], oneHoleMovements, verticesMovements = contourMovements.concat(); + var holesMovements = [], + oneHoleMovements, verticesMovements = contourMovements.concat(); - for ( h = 0, hl = holes.length; h < hl; h ++ ) { + for (h = 0, hl = holes.length; h < hl; h++) { - ahole = holes[ h ]; + ahole = holes[h]; oneHoleMovements = []; - for ( i = 0, il = ahole.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) { + for (i = 0, il = ahole.length, j = il - 1, k = i + 1; i < il; i++, j++, k++) { - if ( j === il ) j = 0; - if ( k === il ) k = 0; + if (j === il) j = 0; + if (k === il) k = 0; // (j)---(i)---(k) - oneHoleMovements[ i ] = getBevelVec( ahole[ i ], ahole[ j ], ahole[ k ] ); + oneHoleMovements[i] = getBevelVec(ahole[i], ahole[j], ahole[k]); } - holesMovements.push( oneHoleMovements ); - verticesMovements = verticesMovements.concat( oneHoleMovements ); + holesMovements.push(oneHoleMovements); + verticesMovements = verticesMovements.concat(oneHoleMovements); } // Loop bevelSegments, 1 for the front, 1 for the back - for ( b = 0; b < bevelSegments; b ++ ) { + for (b = 0; b < bevelSegments; b++) { //for ( b = bevelSegments; b > 0; b -- ) { t = b / bevelSegments; - z = bevelThickness * Math.cos( t * Math.PI / 2 ); - bs = bevelSize * Math.sin( t * Math.PI / 2 ); + z = bevelThickness * Math.cos(t * Math.PI / 2); + bs = bevelSize * Math.sin(t * Math.PI / 2); // contract shape - for ( i = 0, il = contour.length; i < il; i ++ ) { + for (i = 0, il = contour.length; i < il; i++) { - vert = scalePt2( contour[ i ], contourMovements[ i ], bs ); + vert = scalePt2(contour[i], contourMovements[i], bs); - v( vert.x, vert.y, - z ); + v(vert.x, vert.y, -z); } // expand holes - for ( h = 0, hl = holes.length; h < hl; h ++ ) { + for (h = 0, hl = holes.length; h < hl; h++) { - ahole = holes[ h ]; - oneHoleMovements = holesMovements[ h ]; + ahole = holes[h]; + oneHoleMovements = holesMovements[h]; - for ( i = 0, il = ahole.length; i < il; i ++ ) { + for (i = 0, il = ahole.length; i < il; i++) { - vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs ); + vert = scalePt2(ahole[i], oneHoleMovements[i], bs); - v( vert.x, vert.y, - z ); + v(vert.x, vert.y, -z); } @@ -395,24 +465,25 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // Back facing vertices - for ( i = 0; i < vlen; i ++ ) { + for (i = 0; i < vlen; i++) { - vert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ]; + vert = bevelEnabled ? scalePt2(vertices[i], verticesMovements[i], bs) : vertices[i]; - if ( ! extrudeByPath ) { + if (!extrudeByPath) { - v( vert.x, vert.y, 0 ); + v(vert.x, vert.y, 0); - } else { + } + else { // v( vert.x, vert.y + extrudePts[ 0 ].y, extrudePts[ 0 ].x ); - normal.copy( splineTube.normals[ 0 ] ).multiplyScalar( vert.x ); - binormal.copy( splineTube.binormals[ 0 ] ).multiplyScalar( vert.y ); + normal.copy(splineTube.normals[0]).multiplyScalar(vert.x); + binormal.copy(splineTube.binormals[0]).multiplyScalar(vert.y); - position2.copy( extrudePts[ 0 ] ).add( normal ).add( binormal ); + position2.copy(extrudePts[0]).add(normal).add(binormal); - v( position2.x, position2.y, position2.z ); + v(position2.x, position2.y, position2.z); } @@ -423,26 +494,27 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { var s; - for ( s = 1; s <= steps; s ++ ) { + for (s = 1; s <= steps; s++) { - for ( i = 0; i < vlen; i ++ ) { + for (i = 0; i < vlen; i++) { - vert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ]; + vert = bevelEnabled ? scalePt2(vertices[i], verticesMovements[i], bs) : vertices[i]; - if ( ! extrudeByPath ) { + if (!extrudeByPath) { - v( vert.x, vert.y, amount / steps * s ); + v(vert.x, vert.y, amount / steps * s); - } else { + } + else { // v( vert.x, vert.y + extrudePts[ s - 1 ].y, extrudePts[ s - 1 ].x ); - normal.copy( splineTube.normals[ s ] ).multiplyScalar( vert.x ); - binormal.copy( splineTube.binormals[ s ] ).multiplyScalar( vert.y ); + normal.copy(splineTube.normals[s]).multiplyScalar(vert.x); + binormal.copy(splineTube.binormals[s]).multiplyScalar(vert.y); - position2.copy( extrudePts[ s ] ).add( normal ).add( binormal ); + position2.copy(extrudePts[s]).add(normal).add(binormal); - v( position2.x, position2.y, position2.z ); + v(position2.x, position2.y, position2.z); } @@ -454,39 +526,40 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // Add bevel segments planes //for ( b = 1; b <= bevelSegments; b ++ ) { - for ( b = bevelSegments - 1; b >= 0; b -- ) { + for (b = bevelSegments - 1; b >= 0; b--) { t = b / bevelSegments; - z = bevelThickness * Math.cos ( t * Math.PI / 2 ); - bs = bevelSize * Math.sin( t * Math.PI / 2 ); + z = bevelThickness * Math.cos(t * Math.PI / 2); + bs = bevelSize * Math.sin(t * Math.PI / 2); // contract shape - for ( i = 0, il = contour.length; i < il; i ++ ) { + for (i = 0, il = contour.length; i < il; i++) { - vert = scalePt2( contour[ i ], contourMovements[ i ], bs ); - v( vert.x, vert.y, amount + z ); + vert = scalePt2(contour[i], contourMovements[i], bs); + v(vert.x, vert.y, amount + z); } // expand holes - for ( h = 0, hl = holes.length; h < hl; h ++ ) { + for (h = 0, hl = holes.length; h < hl; h++) { - ahole = holes[ h ]; - oneHoleMovements = holesMovements[ h ]; + ahole = holes[h]; + oneHoleMovements = holesMovements[h]; - for ( i = 0, il = ahole.length; i < il; i ++ ) { + for (i = 0, il = ahole.length; i < il; i++) { - vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs ); + vert = scalePt2(ahole[i], oneHoleMovements[i], bs); - if ( ! extrudeByPath ) { + if (!extrudeByPath) { - v( vert.x, vert.y, amount + z ); + v(vert.x, vert.y, amount + z); - } else { + } + else { - v( vert.x, vert.y + extrudePts[ steps - 1 ].y, extrudePts[ steps - 1 ].x + z ); + v(vert.x, vert.y + extrudePts[steps - 1].y, extrudePts[steps - 1].x + z); } @@ -511,17 +584,17 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { function buildLidFaces() { - if ( bevelEnabled ) { + if (bevelEnabled) { var layer = 0; // steps + 1 var offset = vlen * layer; // Bottom faces - for ( i = 0; i < flen; i ++ ) { + for (i = 0; i < flen; i++) { - face = faces[ i ]; - f3( face[ 2 ] + offset, face[ 1 ] + offset, face[ 0 ] + offset ); + face = faces[i]; + f3(face[2] + offset, face[1] + offset, face[0] + offset); } @@ -530,30 +603,31 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // Top faces - for ( i = 0; i < flen; i ++ ) { + for (i = 0; i < flen; i++) { - face = faces[ i ]; - f3( face[ 0 ] + offset, face[ 1 ] + offset, face[ 2 ] + offset ); + face = faces[i]; + f3(face[0] + offset, face[1] + offset, face[2] + offset); } - } else { + } + else { // Bottom faces - for ( i = 0; i < flen; i ++ ) { + for (i = 0; i < flen; i++) { - face = faces[ i ]; - f3( face[ 2 ], face[ 1 ], face[ 0 ] ); + face = faces[i]; + f3(face[2], face[1], face[0]); } // Top faces - for ( i = 0; i < flen; i ++ ) { + for (i = 0; i < flen; i++) { - face = faces[ i ]; - f3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps ); + face = faces[i]; + f3(face[0] + vlen * steps, face[1] + vlen * steps, face[2] + vlen * steps); } @@ -566,13 +640,13 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { function buildSideFaces() { var layeroffset = 0; - sidewalls( contour, layeroffset ); + sidewalls(contour, layeroffset); layeroffset += contour.length; - for ( h = 0, hl = holes.length; h < hl; h ++ ) { + for (h = 0, hl = holes.length; h < hl; h++) { - ahole = holes[ h ]; - sidewalls( ahole, layeroffset ); + ahole = holes[h]; + sidewalls(ahole, layeroffset); //, true layeroffset += ahole.length; @@ -581,122 +655,171 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { } - function sidewalls( contour, layeroffset ) { + function sidewalls(contour, layeroffset) { var j, k; i = contour.length; - while ( -- i >= 0 ) { + while (--i >= 0) { j = i; k = i - 1; - if ( k < 0 ) k = contour.length - 1; + if (k < 0) k = contour.length - 1; //console.log('b', i,j, i-1, k,vertices.length); - var s = 0, sl = steps + bevelSegments * 2; + var s = 0, + sl = steps + bevelSegments * 2; - for ( s = 0; s < sl; s ++ ) { + for (s = 0; s < sl; s++) { var slen1 = vlen * s; - var slen2 = vlen * ( s + 1 ); + var slen2 = vlen * (s + 1); var a = layeroffset + j + slen1, b = layeroffset + k + slen1, c = layeroffset + k + slen2, d = layeroffset + j + slen2; - f4( a, b, c, d, contour, s, sl, j, k ); + f4(a, b, c, d, contour, s, sl, j, k); } } } - - - function v( x, y, z ) { - - scope.vertices.push( new Vector3( x, y, z ) ); + function v(x, y, z) { + + placeholder.push(x); + placeholder.push(y); + placeholder.push(z); } - function f3( a, b, c ) { - a += shapesOffset; - b += shapesOffset; - c += shapesOffset; + function f3(a, b, c) { - scope.faces.push( new Face3( a, b, c, null, null, 0 ) ); + addVertex(a); + addVertex(b); + addVertex(c); - var uvs = uvgen.generateTopUV( scope, a, b, c ); + var nextIndex = verticesArray.length/3; + var uvs = uvgen.generateTopUV( scope, verticesArray , nextIndex - 3, nextIndex - 2, nextIndex - 1 ); - scope.faceVertexUvs[ 0 ].push( uvs ); + uvArray.push(uvs[0].x); + uvArray.push(uvs[0].y); + uvArray.push(uvs[1].x); + uvArray.push(uvs[1].y); + uvArray.push(uvs[2].x); + uvArray.push(uvs[2].y); + //scope.faceVertexUvs[ 0 ].push( uvs ); } - function f4( a, b, c, d, wallContour, stepIndex, stepsLength, contourIndex1, contourIndex2 ) { + function f4(a, b, c, d, wallContour, stepIndex, stepsLength, contourIndex1, contourIndex2) { - a += shapesOffset; - b += shapesOffset; - c += shapesOffset; - d += shapesOffset; + addVertex(a); + addVertex(b); + addVertex(d); - scope.faces.push( new Face3( a, b, d, null, null, 1 ) ); - scope.faces.push( new Face3( b, c, d, null, null, 1 ) ); + addVertex(b); + addVertex(c); + addVertex(d); var uvs = uvgen.generateSideWallUV( scope, a, b, c, d ); + uvArray.push(uvs[0].x); + uvArray.push(uvs[0].y); + uvArray.push(uvs[1].x); + uvArray.push(uvs[1].y); + uvArray.push(uvs[3].x); + uvArray.push(uvs[3].y); + + uvArray.push(uvs[1].x); + uvArray.push(uvs[1].y); + uvArray.push(uvs[2].x); + uvArray.push(uvs[2].y); + uvArray.push(uvs[3].x); + uvArray.push(uvs[3].y); + + //scope.faceVertexUvs[ 0 ].push( [ uvs[ 0 ], uvs[ 1 ], uvs[ 3 ] ] ); + //scope.faceVertexUvs[ 0 ].push( [ uvs[ 1 ], uvs[ 2 ], uvs[ 3 ] ] ); - scope.faceVertexUvs[ 0 ].push( [ uvs[ 0 ], uvs[ 1 ], uvs[ 3 ] ] ); - scope.faceVertexUvs[ 0 ].push( [ uvs[ 1 ], uvs[ 2 ], uvs[ 3 ] ] ); + } + + function addVertex(index){ + + indicesArray.push(verticesArray.length/3); + verticesArray.push(placeholder[index * 3 + 0]); + verticesArray.push(placeholder[index * 3 + 1]); + verticesArray.push(placeholder[index * 3 + 2]); + + } + + if (!options.arrays) { + + this.setIndex(indicesArray); + this.addAttribute('position', new Float32BufferAttribute(verticesArray, 3)); + this.addAttribute('uv', new Float32BufferAttribute(options.arrays.uv, 2)); } }; ExtrudeGeometry.WorldUVGenerator = { - generateTopUV: function ( geometry, indexA, indexB, indexC ) { - - var vertices = geometry.vertices; + generateTopUV: function(geometry, vertices , indexA, indexB, indexC) { - var a = vertices[ indexA ]; - var b = vertices[ indexB ]; - var c = vertices[ indexC ]; + var a_x = vertices[indexA * 3]; + var a_y = vertices[indexA * 3 + 1]; + var b_x = vertices[indexB * 3]; + var b_y = vertices[indexB * 3 + 1]; + var c_x = vertices[indexC * 3]; + var c_y = vertices[indexC * 3 + 1]; return [ - new Vector2( a.x, a.y ), - new Vector2( b.x, b.y ), - new Vector2( c.x, c.y ) + new Vector2(a_x, a_y), + new Vector2(b_x, b_y), + new Vector2(c_x, c_y) ]; }, - generateSideWallUV: function ( geometry, indexA, indexB, indexC, indexD ) { + generateSideWallUV: function(geometry, vertices, indexA, indexB, indexC, indexD) { - var vertices = geometry.vertices; - var a = vertices[ indexA ]; - var b = vertices[ indexB ]; - var c = vertices[ indexC ]; - var d = vertices[ indexD ]; - if ( Math.abs( a.y - b.y ) < 0.01 ) { + var a = vertices[indexA]; + + var a_x = vertices[indexA * 3]; + var a_y = vertices[indexA * 3 + 1]; + var a_z = vertices[indexA * 3 + 2]; + var b_x = vertices[indexB * 3]; + var b_y = vertices[indexB * 3 + 1]; + var b_z = vertices[indexB * 3 + 2]; + var c_x = vertices[indexC * 3]; + var c_y = vertices[indexC * 3 + 1]; + var c_z = vertices[indexC * 3 + 2]; + var d_x = vertices[indexD * 3]; + var d_y = vertices[indexD * 3 + 1]; + var d_z = vertices[indexD * 3 + 2]; + + if (Math.abs(a_y - b_y) < 0.01) { return [ - new Vector2( a.x, 1 - a.z ), - new Vector2( b.x, 1 - b.z ), - new Vector2( c.x, 1 - c.z ), - new Vector2( d.x, 1 - d.z ) + new Vector2(a_x, 1 - a_z), + new Vector2(b_x, 1 - b_z), + new Vector2(c_x, 1 - c_z), + new Vector2(d_x, 1 - d_z) ]; - } else { + } + else { return [ - new Vector2( a.y, 1 - a.z ), - new Vector2( b.y, 1 - b.z ), - new Vector2( c.y, 1 - c.z ), - new Vector2( d.y, 1 - d.z ) + new Vector2(a_y, 1 - a_z), + new Vector2(b_y, 1 - b_z), + new Vector2(c_y, 1 - c_z), + new Vector2(d_y, 1 - d_z) ]; } @@ -705,4 +828,6 @@ ExtrudeGeometry.WorldUVGenerator = { }; -export { ExtrudeGeometry }; +export { + ExtrudeGeometry +};
false
Other
mrdoob
three.js
17cc0b08bd357d8cff144bcf2d066f8bf1ee7028.json
Use quatEquals on quaternions eulerEquals was being used to compare quaternions. The fix should have no effects on behaviour.
test/unit/src/math/Euler.js
@@ -80,7 +80,7 @@ QUnit.test( "Quaternion.setFromEuler/Euler.fromQuaternion", function( assert ) { var v2 = new THREE.Euler().setFromQuaternion( q, v.order ); var q2 = new THREE.Quaternion().setFromEuler( v2 ); - assert.ok( eulerEquals( q, q2 ), "Passed!" ); + assert.ok( quatEquals( q, q2 ), "Passed!" ); } });
false
Other
mrdoob
three.js
241247c85262d6af884e7f0973a04448376008e3.json
Add channel note to aoMap.
docs/api/materials/MeshStandardMaterial.html
@@ -97,7 +97,7 @@ <h3>[property:Texture alphaMap]</h3> </div> <h3>[property:Texture aoMap]</h3> - <div>The ambient occlusion map. Default is null.</div> + <div>The red channel of this texture is used as the ambient occlusion map. Default is null.</div> <h3>[property:Float aoMapIntensity]</h3> <div>Intensity of the ambient occlusion effect. Default is 1. Zero is no occlusion effect.</div>
false
Other
mrdoob
three.js
06b27286cbb551ae0711ec0df71a5900e94aae48.json
remove MultiMaterial from canvas examples
examples/canvas_geometry_panorama.html
@@ -81,7 +81,7 @@ ]; - mesh = new THREE.Mesh( new THREE.BoxGeometry( 300, 300, 300, 7, 7, 7 ), new THREE.MultiMaterial( materials ) ); + mesh = new THREE.Mesh( new THREE.BoxGeometry( 300, 300, 300, 7, 7, 7 ), materials ); mesh.scale.x = - 1; scene.add( mesh );
true
Other
mrdoob
three.js
06b27286cbb551ae0711ec0df71a5900e94aae48.json
remove MultiMaterial from canvas examples
examples/canvas_geometry_panorama_fisheye.html
@@ -81,7 +81,7 @@ ]; - mesh = new THREE.Mesh( new THREE.BoxGeometry( 300, 300, 300, 7, 7, 7 ), new THREE.MultiMaterial( materials ) ); + mesh = new THREE.Mesh( new THREE.BoxGeometry( 300, 300, 300, 7, 7, 7 ), materials ); mesh.scale.x = - 1; scene.add( mesh );
true
Other
mrdoob
three.js
06b27286cbb551ae0711ec0df71a5900e94aae48.json
remove MultiMaterial from canvas examples
examples/canvas_geometry_text.html
@@ -92,12 +92,12 @@ var centerOffset = -0.5 * ( geometry.boundingBox.max.x - geometry.boundingBox.min.x ); - var material = new THREE.MultiMaterial( [ + var materials = [ new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, overdraw: 0.5 } ), new THREE.MeshBasicMaterial( { color: 0x000000, overdraw: 0.5 } ) - ] ); + ]; - var mesh = new THREE.Mesh( geometry, material ); + var mesh = new THREE.Mesh( geometry, materials ); mesh.position.x = centerOffset; mesh.position.y = 100;
true
Other
mrdoob
three.js
06b27286cbb551ae0711ec0df71a5900e94aae48.json
remove MultiMaterial from canvas examples
examples/canvas_materials.html
@@ -93,7 +93,7 @@ } - materials.push( new THREE.MultiMaterial( materials ) ); + materials.push( materials ); objects = [];
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/js/Car.js
@@ -299,8 +299,8 @@ THREE.Car = function () { var s = scope.modelScale, delta = new THREE.Vector3(); - var bodyFaceMaterial = new THREE.MultiMaterial( scope.bodyMaterials ); - var wheelFaceMaterial = new THREE.MultiMaterial( scope.wheelMaterials ); + var bodyFaceMaterial = scope.bodyMaterials; + var wheelFaceMaterial = scope.wheelMaterials; // body
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/js/UCSCharacter.js
@@ -44,7 +44,7 @@ THREE.UCSCharacter = function() { geometry.computeBoundingBox(); geometry.computeVertexNormals(); - mesh = new THREE.SkinnedMesh( geometry, new THREE.MultiMaterial() ); + mesh = new THREE.SkinnedMesh( geometry, [] ); mesh.name = config.character; scope.root.add( mesh );
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_animation_skinning_morph.html
@@ -215,7 +215,7 @@ } - mesh = new THREE.SkinnedMesh( geometry, new THREE.MultiMaterial( materials ) ); + mesh = new THREE.SkinnedMesh( geometry, materials ); mesh.name = "Knight Mesh"; mesh.position.set( x, y - bb.min.y * s, z ); mesh.scale.set( s, s, s ); @@ -225,7 +225,7 @@ mesh.receiveShadow = true; - mesh2 = new THREE.SkinnedMesh( geometry, new THREE.MultiMaterial( materials ) ); + mesh2 = new THREE.SkinnedMesh( geometry, materials ); mesh2.name = "Lil' Bro Mesh"; mesh2.position.set( x - 240, y - bb.min.y * s, z + 500 ); mesh2.scale.set( s / 2, s / 2, s / 2 );
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_effects_parallaxbarrier.html
@@ -517,7 +517,7 @@ } - function attachButtonMaterials( materials, faceMaterial, material_indices, car ) { + function attachButtonMaterials( materials, faceMaterials, material_indices, car ) { for( var i = 0; i < materials.length; i++ ) { @@ -526,7 +526,7 @@ for ( var j = 0; j < material_indices.length; j ++ ) { - faceMaterial.materials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ]; + faceMaterials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ]; } @@ -540,7 +540,7 @@ geometry.sortFacesByMaterialIndex(); - var m = new THREE.MultiMaterial(), + var m = [], s = CARS[ car ].scale * 1, r = CARS[ car ].init_rotation, materials = CARS[ car ].materials, @@ -549,7 +549,7 @@ for( var i in CARS[ car ].mmap ) { - m.materials[ i ] = CARS[ car ].mmap[ i ]; + m[ i ] = CARS[ car ].mmap[ i ]; }
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_geometry_colors_blender.html
@@ -107,7 +107,7 @@ materials[ 0 ].shading = THREE.FlatShading; - mesh = new THREE.Mesh( geometry, new THREE.MultiMaterial( materials ) ); + mesh = new THREE.Mesh( geometry, materials ); mesh.position.x = 400; mesh.scale.x = mesh.scale.y = mesh.scale.z = 250; scene.add( mesh ); @@ -118,7 +118,7 @@ materials[ 0 ].shading = THREE.FlatShading; - mesh2 = new THREE.Mesh( geometry, new THREE.MultiMaterial( materials ) ); + mesh2 = new THREE.Mesh( geometry, materials ); mesh2.position.x = - 400; mesh2.scale.x = mesh2.scale.y = mesh2.scale.z = 250; scene.add( mesh2 );
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_geometry_extrude_shapes.html
@@ -170,7 +170,7 @@ var geometry = new THREE.ExtrudeGeometry( shape, extrudeSettings ); - var mesh = new THREE.Mesh( geometry, new THREE.MultiMaterial( materials ) ); + var mesh = new THREE.Mesh( geometry, materials ); mesh.position.set( 50, 100, 50 );
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_geometry_text.html
@@ -52,7 +52,7 @@ var camera, cameraTarget, scene, renderer; - var group, textMesh1, textMesh2, textGeo, material; + var group, textMesh1, textMesh2, textGeo, materials; var firstLetter = true; @@ -181,10 +181,10 @@ } - material = new THREE.MultiMaterial( [ + materials = [ new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), // front new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) // side - ] ); + ]; group = new THREE.Group(); group.position.y = 100; @@ -427,7 +427,7 @@ var centerOffset = -0.5 * ( textGeo.boundingBox.max.x - textGeo.boundingBox.min.x ); - textMesh1 = new THREE.Mesh( textGeo, material ); + textMesh1 = new THREE.Mesh( textGeo, materials ); textMesh1.position.x = centerOffset; textMesh1.position.y = hover; @@ -440,7 +440,7 @@ if ( mirror ) { - textMesh2 = new THREE.Mesh( textGeo, material ); + textMesh2 = new THREE.Mesh( textGeo, materials ); textMesh2.position.x = centerOffset; textMesh2.position.y = -hover;
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_geometry_text_earcut.html
@@ -110,7 +110,7 @@ var camera, cameraTarget, scene, renderer; - var group, textMesh1, textMesh2, textGeo, material; + var group, textMesh1, textMesh2, textGeo, materials; var firstLetter = true; @@ -239,10 +239,10 @@ } - material = new THREE.MultiMaterial( [ + materials = [ new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), // front new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) // side - ] ); + ]; group = new THREE.Group(); group.position.y = 100; @@ -485,7 +485,7 @@ var centerOffset = -0.5 * ( textGeo.boundingBox.max.x - textGeo.boundingBox.min.x ); - textMesh1 = new THREE.Mesh( textGeo, material ); + textMesh1 = new THREE.Mesh( textGeo, materials ); textMesh1.position.x = centerOffset; textMesh1.position.y = hover; @@ -498,7 +498,7 @@ if ( mirror ) { - textMesh2 = new THREE.Mesh( textGeo, material ); + textMesh2 = new THREE.Mesh( textGeo, materials ); textMesh2.position.x = centerOffset; textMesh2.position.y = -hover;
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_geometry_text_pnltri.html
@@ -82,7 +82,7 @@ var camera, cameraTarget, scene, renderer; - var group, textMesh1, textMesh2, textGeo, material; + var group, textMesh1, textMesh2, textGeo, materials; var firstLetter = true; @@ -211,10 +211,10 @@ } - material = new THREE.MultiMaterial( [ + materials = [ new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), // front new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) // side - ] ); + ]; group = new THREE.Group(); group.position.y = 100; @@ -457,7 +457,7 @@ var centerOffset = -0.5 * ( textGeo.boundingBox.max.x - textGeo.boundingBox.min.x ); - textMesh1 = new THREE.Mesh( textGeo, material ); + textMesh1 = new THREE.Mesh( textGeo, materials ); textMesh1.position.x = centerOffset; textMesh1.position.y = hover; @@ -470,7 +470,7 @@ if ( mirror ) { - textMesh2 = new THREE.Mesh( textGeo, material ); + textMesh2 = new THREE.Mesh( textGeo, materials ); textMesh2.position.x = centerOffset; textMesh2.position.y = -hover;
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_loader_ctm_materials.html
@@ -254,23 +254,6 @@ // - function createScene( geometry, materials, x, y, z, s ) { - - geometry.center(); - - hackMaterials( materials ); - - var material = new THREE.MultiMaterial( materials ); - - mesh = new THREE.Mesh( geometry, material ); - mesh.position.set( x, y, z ); - mesh.scale.set( s, s, s ); - scene.add( mesh ); - - } - - // - function onWindowResize( event ) { SCREEN_WIDTH = window.innerWidth;
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_loader_json_blender.html
@@ -108,8 +108,6 @@ material.morphTargets = true; material.color.setHex( 0xffaaaa ); - var faceMaterial = new THREE.MultiMaterial( materials ); - for ( var i = 0; i < 729; i ++ ) { // random placement in a grid @@ -121,7 +119,7 @@ if ( Math.abs( x ) < 2 && Math.abs( z ) < 2 ) continue; - mesh = new THREE.Mesh( geometry, faceMaterial ); + mesh = new THREE.Mesh( geometry, materials ); var s = THREE.Math.randFloat( 0.00075, 0.001 ); mesh.scale.set( s, s, s );
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_loader_json_objconverter.html
@@ -217,7 +217,7 @@ <h1>OBJ to Three.js converter test</h1> function createScene( geometry, materials, x, y, z, b ) { - zmesh = new THREE.Mesh( geometry, new THREE.MultiMaterial( materials ) ); + zmesh = new THREE.Mesh( geometry, materials ); zmesh.position.set( x, y, z ); zmesh.scale.set( 3, 3, 3 ); scene.add( zmesh );
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_materials.html
@@ -108,7 +108,7 @@ } - addMesh( geometry, new THREE.MultiMaterial( materials ) ); + addMesh( geometry, materials ); particleLight = new THREE.Mesh( new THREE.SphereGeometry( 4, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0xffffff } ) ); scene.add( particleLight );
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_materials_cars.html
@@ -516,7 +516,7 @@ } - function attachButtonMaterials( materials, faceMaterial, material_indices, car ) { + function attachButtonMaterials( materials, faceMaterials, material_indices, car ) { for( var i = 0; i < materials.length; i ++ ) { @@ -525,7 +525,7 @@ for ( var j = 0; j < material_indices.length; j ++ ) { - faceMaterial.materials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ]; + faceMaterials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ]; } @@ -539,7 +539,7 @@ geometry.sortFacesByMaterialIndex(); - var m = new THREE.MultiMaterial(), + var m = [], s = CARS[ car ].scale * 1, r = CARS[ car ].init_rotation, materials = CARS[ car ].materials, @@ -548,7 +548,7 @@ for ( var i in CARS[ car ].mmap ) { - m.materials[ i ] = CARS[ car ].mmap[ i ]; + m[ i ] = CARS[ car ].mmap[ i ]; }
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_materials_lightmap.html
@@ -149,7 +149,7 @@ } - var mesh = new THREE.Mesh( geometry, new THREE.MultiMaterial( materials ) ); + var mesh = new THREE.Mesh( geometry, materials ); mesh.scale.multiplyScalar( 100 ); scene.add( mesh );
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_nearestneighbour.html
@@ -109,7 +109,7 @@ ]; - mesh = new THREE.Mesh( new THREE.BoxGeometry( 10000, 10000, 10000, 7, 7, 7 ), new THREE.MultiMaterial( materials ) ); + mesh = new THREE.Mesh( new THREE.BoxGeometry( 10000, 10000, 10000, 7, 7, 7 ), materials ); mesh.scale.x = - 1; scene.add(mesh);
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_objects_update.html
@@ -47,22 +47,22 @@ // - var object = createObject( createMultiMaterial(), 1 ); + var object = createObject( createMaterials(), 1 ); object.position.set( -100, 100, 0 ); scene.add( object ); objectNewGeometry = object; - object = createObject( createMultiMaterial(), 1 ); + object = createObject( createMaterials(), 1 ); object.position.set( 100, 100, 0 ); scene.add( object ); objectToggleAddRemove = object; - object = createObject( createMultiMaterial(), 4 ); + object = createObject( createMaterials(), 4 ); object.position.set( -100, -100, 0 ); scene.add( object ); objectRandomizeFaces = object; - object = createObject( createMultiMaterial(), 4 ); + object = createObject( createMaterials(), 4 ); object.position.set( 100, -100, 0 ); scene.add( object ); objectRandomizeMaterialIndices = object; @@ -99,7 +99,7 @@ } - function createMultiMaterial(){ + function createMaterials(){ var materials = [ new THREE.MeshBasicMaterial( { color: 0xff0000 } ), new THREE.MeshBasicMaterial( { color: 0xffff00 } ), @@ -109,7 +109,7 @@ new THREE.MeshBasicMaterial( { color: 0xff00ff } ) ]; - return new THREE.MultiMaterial( materials ); + return materials; } function onWindowResize() {
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_panorama_cube.html
@@ -74,7 +74,7 @@ } - var skyBox = new THREE.Mesh( new THREE.CubeGeometry( 1, 1, 1 ), new THREE.MultiMaterial( materials ) ); + var skyBox = new THREE.Mesh( new THREE.CubeGeometry( 1, 1, 1 ), materials ); skyBox.applyMatrix( new THREE.Matrix4().makeScale( 1, 1, - 1 ) ); scene.add( skyBox );
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_simple_gi.html
@@ -42,7 +42,9 @@ THREE.Mesh.prototype.clone = function () { - return new this.constructor( this.geometry.clone(), this.material.clone() ).copy( this ); + var newMaterial = ( this.material.isMaterial ) ? this.material.clone() : this.material.slice(); + + return new this.constructor( this.geometry.clone(), newMaterial ).copy( this ); }; @@ -211,9 +213,8 @@ } var geometry = new THREE.BoxBufferGeometry( 3, 3, 3 ); - var material = new THREE.MultiMaterial( materials ); - var mesh = new THREE.Mesh( geometry, material ); + var mesh = new THREE.Mesh( geometry, materials ); scene.add( mesh ); //
true
Other
mrdoob
three.js
9f9fbdee47a5a227fcf334c427dfd81689f297ee.json
remove use of MuliMaterial in webGL examples
examples/webgl_skinning_simple.html
@@ -69,7 +69,7 @@ } - skinnedMesh = new THREE.SkinnedMesh(geometry, new THREE.MultiMaterial(materials)); + skinnedMesh = new THREE.SkinnedMesh(geometry, materials ); skinnedMesh.scale.set( 1, 1, 1 ); // Note: We test the corresponding code path with this example -
true
Other
mrdoob
three.js
6028312ec0fe149b5534dd5de7b875eaeb148fbc.json
Revise logic as per discussion in #10883
examples/js/loaders/STLLoader.js
@@ -70,55 +70,23 @@ THREE.STLLoader.prototype = { } - // Do we see 'solid' in the first few bytes of the data? - // An ASCII STL data must begin with 'solid ' as the first six bytes. // However, ASCII STLs lacking the SPACE after the 'd' are known to be - // plentiful. - - // This check can likely be restricted to the first 6 bytes of - // the STL data. It's here applied to the first 50 bytes for - // no particular good reason. - - var fileLength = reader.byteLength; - if ( fileLength > 50 ) fileLength = 50; + // plentiful. So, check the first 5 bytes for 'solid'. // US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd' var solid = [ 115, 111, 108, 105, 100 ]; - - var i = 0; - for ( var index = 0; index < fileLength; index ++ ) { - if ( reader.getUint8( index, false ) == solid[i] ) { - - i++; - if ( i == 5 ) { + for ( var i = 0; i < 5; i ++ ) { - // 'solid' seen near the start of the file - return false; + // If solid[ i ] does not match the i-th byte, then it is not an + // ASCII STL; hence, it is binary and return true. - } + if ( solid[ i ] != reader.getUint8( i, false ) ) return true; - } else { - - i = 0; - - } } - // some binary files will have different size from expected, - // checking characters higher than ASCII to confirm is binary - var fileLength = reader.byteLength; - for ( var index = 0; index < fileLength; index ++ ) { - - if ( reader.getUint8( index, false ) > 127 ) { - - return true; - - } - - } - + // First 5 bytes read "solid"; declare it to be an ASCII STL return false; };
false
Other
mrdoob
three.js
de1531b3185590e1b4f50c0e895bca786c801715.json
ignore plane render
examples/js/Mirror.js
@@ -6,6 +6,8 @@ THREE.Mirror = function ( width, height, options ) { THREE.Mesh.call( this, new THREE.PlaneBufferGeometry( width, height ) ); + if ( options.render === false ) this.geometry.setDrawRange( 0, 0 ); + var scope = this; scope.name = 'mirror_' + scope.id;
true
Other
mrdoob
three.js
de1531b3185590e1b4f50c0e895bca786c801715.json
ignore plane render
examples/webgl_mirror_nodes.html
@@ -152,7 +152,7 @@ var planeGeo = new THREE.PlaneBufferGeometry( 100.1, 100.1 ); // MIRROR planes - var groundMirror = new THREE.Mirror( 100, 100, { clipBias: 0.003, textureWidth: WIDTH, textureHeight: HEIGHT } ); + var groundMirror = new THREE.Mirror( 100, 100, { clipBias: 0.003, textureWidth: WIDTH, textureHeight: HEIGHT, render: false } ); var mask = new THREE.SwitchNode( new THREE.TextureNode( decalDiffuse ), 'w' ); var maskFlip = new THREE.Math1Node( mask, THREE.Math1Node.INVERT );
true
Other
mrdoob
three.js
fae0177d6fca237b6b66d91b556f075a797fe7bd.json
update mirror nodes
examples/js/nodes/inputs/MirrorNode.js
@@ -1,10 +1,10 @@ -THREE.MirrorNode = function( renderer, camera, options ) { +THREE.MirrorNode = function( mirror, camera, options ) { THREE.TempNode.call( this, 'v4' ); - this.mirror = renderer instanceof THREE.Mirror ? renderer : new THREE.Mirror( renderer, camera, options ); + this.mirror = mirror; - this.textureMatrix = new THREE.Matrix4Node( this.mirror.textureMatrix ); + this.textureMatrix = new THREE.Matrix4Node( this.mirror.material.uniforms.textureMatrix.value ); this.worldPosition = new THREE.PositionNode( THREE.PositionNode.WORLD );
true
Other
mrdoob
three.js
fae0177d6fca237b6b66d91b556f075a797fe7bd.json
update mirror nodes
examples/webgl_mirror_nodes.html
@@ -119,7 +119,6 @@ var gui = new dat.GUI(); - var groundMirror; var sphereGroup, smallSphere; var groundMirrorMaterial; @@ -153,7 +152,7 @@ var planeGeo = new THREE.PlaneBufferGeometry( 100.1, 100.1 ); // MIRROR planes - groundMirror = new THREE.Mirror( renderer, camera, { clipBias: 0.003, textureWidth: WIDTH, textureHeight: HEIGHT, color: 0x777777 } ); + var groundMirror = new THREE.Mirror( 100, 100, { clipBias: 0.003, textureWidth: WIDTH, textureHeight: HEIGHT } ); var mask = new THREE.SwitchNode( new THREE.TextureNode( decalDiffuse ), 'w' ); var maskFlip = new THREE.Math1Node( mask, THREE.Math1Node.INVERT );
true
Other
mrdoob
three.js
48cfde8e8f17b4a775d0e23372c1b121eb1adc1e.json
Remove unnecessary delete.
examples/js/loaders/GLTFLoader.js
@@ -1118,8 +1118,6 @@ THREE.GLTFLoader = ( function () { materialParams.specularMap = dependencies.textures[ materialValues.specular ]; - delete materialParams.specular; - } if ( materialValues.shininess !== undefined ) {
false
Other
mrdoob
three.js
b2fba537f0e0103efebbef9813313fa7ee5e6a11.json
Add support for glTF emission textures.
examples/js/loaders/GLTFLoader.js
@@ -1088,8 +1088,14 @@ THREE.GLTFLoader = ( function () { materialParams.emissive = new THREE.Color().fromArray( materialValues.emission ); + } else if ( typeof( materialValues.emission ) === 'string' ) { + + materialParams.map = dependencies.textures[ materialValues.emission ]; + } + delete materialParams.emission; + if ( Array.isArray( materialValues.specular ) ) { materialParams.specular = new THREE.Color().fromArray( materialValues.specular );
false
Other
mrdoob
three.js
465d2afed38e24972f381118eee9916a275a78aa.json
Set key event handler on control DOM element
examples/js/controls/FirstPersonControls.js
@@ -266,8 +266,8 @@ THREE.FirstPersonControls = function ( object, domElement ) { this.domElement.removeEventListener( 'mousemove', _onMouseMove, false ); this.domElement.removeEventListener( 'mouseup', _onMouseUp, false ); - window.removeEventListener( 'keydown', _onKeyDown, false ); - window.removeEventListener( 'keyup', _onKeyUp, false ); + this.domElement.removeEventListener( 'keydown', _onKeyDown, false ); + this.domElement.removeEventListener( 'keyup', _onKeyUp, false ); }; @@ -282,8 +282,8 @@ THREE.FirstPersonControls = function ( object, domElement ) { this.domElement.addEventListener( 'mousedown', _onMouseDown, false ); this.domElement.addEventListener( 'mouseup', _onMouseUp, false ); - window.addEventListener( 'keydown', _onKeyDown, false ); - window.addEventListener( 'keyup', _onKeyUp, false ); + this.domElement.addEventListener( 'keydown', _onKeyDown, false ); + this.domElement.addEventListener( 'keyup', _onKeyUp, false ); function bind( scope, fn ) {
true
Other
mrdoob
three.js
465d2afed38e24972f381118eee9916a275a78aa.json
Set key event handler on control DOM element
examples/js/controls/FlyControls.js
@@ -267,8 +267,8 @@ THREE.FlyControls = function ( object, domElement ) { this.domElement.removeEventListener( 'mousemove', _mousemove, false ); this.domElement.removeEventListener( 'mouseup', _mouseup, false ); - window.removeEventListener( 'keydown', _keydown, false ); - window.removeEventListener( 'keyup', _keyup, false ); + this.domElement.removeEventListener( 'keydown', _keydown, false ); + this.domElement.removeEventListener( 'keyup', _keyup, false ); }; @@ -284,8 +284,8 @@ THREE.FlyControls = function ( object, domElement ) { this.domElement.addEventListener( 'mousedown', _mousedown, false ); this.domElement.addEventListener( 'mouseup', _mouseup, false ); - window.addEventListener( 'keydown', _keydown, false ); - window.addEventListener( 'keyup', _keyup, false ); + this.domElement.addEventListener( 'keydown', _keydown, false ); + this.domElement.addEventListener( 'keyup', _keyup, false ); this.updateMovementVector(); this.updateRotationVector();
true
Other
mrdoob
three.js
465d2afed38e24972f381118eee9916a275a78aa.json
Set key event handler on control DOM element
examples/js/controls/OrbitControls.js
@@ -221,7 +221,7 @@ THREE.OrbitControls = function ( object, domElement ) { document.removeEventListener( 'mousemove', onMouseMove, false ); document.removeEventListener( 'mouseup', onMouseUp, false ); - window.removeEventListener( 'keydown', onKeyDown, false ); + scope.domElement.removeEventListener( 'keydown', onKeyDown, false ); //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here? @@ -879,7 +879,7 @@ THREE.OrbitControls = function ( object, domElement ) { scope.domElement.addEventListener( 'touchend', onTouchEnd, false ); scope.domElement.addEventListener( 'touchmove', onTouchMove, false ); - window.addEventListener( 'keydown', onKeyDown, false ); + scope.domElement.addEventListener( 'keydown', onKeyDown, false ); // force an update at start
true
Other
mrdoob
three.js
465d2afed38e24972f381118eee9916a275a78aa.json
Set key event handler on control DOM element
examples/js/controls/OrthographicTrackballControls.js
@@ -379,7 +379,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) { if ( _this.enabled === false ) return; - window.removeEventListener( 'keydown', keydown ); + _this.domElement.removeEventListener( 'keydown', keydown ); _prevState = _state; @@ -409,7 +409,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) { _state = _prevState; - window.addEventListener( 'keydown', keydown, false ); + _this.domElement.addEventListener( 'keydown', keydown, false ); } @@ -609,8 +609,8 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) { document.removeEventListener( 'mousemove', mousemove, false ); document.removeEventListener( 'mouseup', mouseup, false ); - window.removeEventListener( 'keydown', keydown, false ); - window.removeEventListener( 'keyup', keyup, false ); + this.domElement.removeEventListener( 'keydown', keydown, false ); + this.domElement.removeEventListener( 'keyup', keyup, false ); }; @@ -622,8 +622,8 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) { this.domElement.addEventListener( 'touchend', touchend, false ); this.domElement.addEventListener( 'touchmove', touchmove, false ); - window.addEventListener( 'keydown', keydown, false ); - window.addEventListener( 'keyup', keyup, false ); + this.domElement.addEventListener( 'keydown', keydown, false ); + this.domElement.addEventListener( 'keyup', keyup, false ); this.handleResize();
true
Other
mrdoob
three.js
465d2afed38e24972f381118eee9916a275a78aa.json
Set key event handler on control DOM element
examples/js/controls/TrackballControls.js
@@ -356,7 +356,7 @@ THREE.TrackballControls = function ( object, domElement ) { if ( _this.enabled === false ) return; - window.removeEventListener( 'keydown', keydown ); + _this.domElement.removeEventListener( 'keydown', keydown ); _prevState = _state; @@ -386,7 +386,7 @@ THREE.TrackballControls = function ( object, domElement ) { _state = _prevState; - window.addEventListener( 'keydown', keydown, false ); + _this.domElement.addEventListener( 'keydown', keydown, false ); } @@ -596,8 +596,8 @@ THREE.TrackballControls = function ( object, domElement ) { document.removeEventListener( 'mousemove', mousemove, false ); document.removeEventListener( 'mouseup', mouseup, false ); - window.removeEventListener( 'keydown', keydown, false ); - window.removeEventListener( 'keyup', keyup, false ); + this.domElement.removeEventListener( 'keydown', keydown, false ); + this.domElement.removeEventListener( 'keyup', keyup, false ); }; @@ -609,8 +609,8 @@ THREE.TrackballControls = function ( object, domElement ) { this.domElement.addEventListener( 'touchend', touchend, false ); this.domElement.addEventListener( 'touchmove', touchmove, false ); - window.addEventListener( 'keydown', keydown, false ); - window.addEventListener( 'keyup', keyup, false ); + this.domElement.addEventListener( 'keydown', keydown, false ); + this.domElement.addEventListener( 'keyup', keyup, false ); this.handleResize();
true
Other
mrdoob
three.js
6c513a0660a299649f121717b3fc26801dc5af22.json
Fix Quaternion accessors
src/math/Quaternion.js
@@ -89,61 +89,81 @@ Object.assign( Quaternion, { } ); -Object.assign( Quaternion.prototype, { +Object.defineProperties( Quaternion.prototype, { - constructor: Quaternion, + "x" : { - get x () { + get: function () { - return this._x; + return this._x; - }, + }, - set x ( value ) { + set: function ( value ) { - this._x = value; - this.onChangeCallback(); + this._x = value; + this.onChangeCallback(); + + } }, - get y () { + "y" : { - return this._y; + get: function () { - }, + return this._y; - set y ( value ) { + }, - this._y = value; - this.onChangeCallback(); + set: function ( value ) { + + this._y = value; + this.onChangeCallback(); + + } }, - get z () { + "z" : { - return this._z; + get: function () { - }, + return this._z; - set z ( value ) { + }, - this._z = value; - this.onChangeCallback(); + set: function ( value ) { + + this._z = value; + this.onChangeCallback(); + + } }, - get w () { + "w" : { - return this._w; + get: function () { - }, + return this._w; - set w ( value ) { + }, - this._w = value; - this.onChangeCallback(); + set: function ( value ) { - }, + this._w = value; + this.onChangeCallback(); + + } + + } + +}); + +Object.assign( Quaternion.prototype, { + + constructor: Quaternion, set: function ( x, y, z, w ) {
false
Other
mrdoob
three.js
e0f8526922ae92a9e3eb289c58e9a19ba92de6f6.json
Fix Euler accessors
src/math/Euler.js
@@ -22,63 +22,83 @@ Euler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ]; Euler.DefaultOrder = 'XYZ'; -Object.assign( Euler.prototype, { +Object.defineProperties( Euler.prototype, { - constructor: Euler, + "x" : { - isEuler: true, + get: function () { - get x () { + return this._x; - return this._x; + }, - }, + set: function ( value ) { - set x ( value ) { + this._x = value; + this.onChangeCallback(); - this._x = value; - this.onChangeCallback(); + } }, - get y () { + "y" : { - return this._y; + get: function () { - }, + return this._y; - set y ( value ) { + }, - this._y = value; - this.onChangeCallback(); + set: function ( value ) { + + this._y = value; + this.onChangeCallback(); + + } }, - get z () { + "z" : { - return this._z; + get: function () { - }, + return this._z; - set z ( value ) { + }, - this._z = value; - this.onChangeCallback(); + set: function ( value ) { + + this._z = value; + this.onChangeCallback(); + + } }, - get order () { + "order" : { - return this._order; + get: function () { - }, + return this._order; - set order ( value ) { + }, - this._order = value; - this.onChangeCallback(); + set: function ( value ) { - }, + this._order = value; + this.onChangeCallback(); + + } + + } + +}); + +Object.assign( Euler.prototype, { + + constructor: Euler, + + isEuler: true, set: function ( x, y, z, order ) {
false
Other
mrdoob
three.js
d4ee29216cfbd37cff37d02efbf0ed5179745376.json
Fix Material accessors
src/materials/Material.js
@@ -63,24 +63,27 @@ function Material() { } -Object.assign( Material.prototype, EventDispatcher.prototype, { - - constructor: Material, - - isMaterial: true, +Object.defineProperty( Material.prototype, "needsUpdate", { - get needsUpdate() { + get: function() { return this._needsUpdate; }, - - set needsUpdate( value ) { + set: function(value) { if ( value === true ) this.update(); this._needsUpdate = value; - }, + } + +}); + +Object.assign( Material.prototype, EventDispatcher.prototype, { + + constructor: Material, + + isMaterial: true, setValues: function ( values ) {
false
Other
mrdoob
three.js
9757d97f67c70d6c85c828d0973aa85bab7a2b3c.json
Fix BufferAttribute accessors
src/core/BufferAttribute.js
@@ -32,6 +32,12 @@ function BufferAttribute( array, itemSize, normalized ) { } +Object.defineProperty( BufferAttribute.prototype, "needsUpdate", { + + set: function(value) { if ( value === true ) this.version ++; } + +}); + Object.assign( BufferAttribute.prototype, { constructor: BufferAttribute,
false
Other
mrdoob
three.js
5f2187fbef3960f2111d498adf5e6a8c50404946.json
Improve Vector2 closure performance
src/math/Vector2.js
@@ -269,17 +269,11 @@ Object.assign( Vector2.prototype, { clampScalar: function () { - var min, max; + var min = new Vector2(); + var max = new Vector2(); return function clampScalar( minVal, maxVal ) { - if ( min === undefined ) { - - min = new Vector2(); - max = new Vector2(); - - } - min.set( minVal, minVal ); max.set( maxVal, maxVal );
false
Other
mrdoob
three.js
d5b9bc6806ea51490eed10ce56f550cf9459bb80.json
Improve Triangle closure performance
src/math/Triangle.js
@@ -193,19 +193,13 @@ Object.assign( Triangle.prototype, { closestPointToPoint: function () { - var plane, edgeList, projectedPoint, closestPoint; + var plane = new Plane(); + var edgeList = [ new Line3(), new Line3(), new Line3() ]; + var projectedPoint = new Vector3(); + var closestPoint = new Vector3(); return function closestPointToPoint( point, optionalTarget ) { - if ( plane === undefined ) { - - plane = new Plane(); - edgeList = [ new Line3(), new Line3(), new Line3() ]; - projectedPoint = new Vector3(); - closestPoint = new Vector3(); - - } - var result = optionalTarget || new Vector3(); var minDistance = Infinity;
false
Other
mrdoob
three.js
563060ae23cc8602b84588e89a49a5c17428fc6c.json
Improve Quaternion closure performance
src/math/Quaternion.js
@@ -332,7 +332,8 @@ Object.assign( Quaternion.prototype, { // assumes direction vectors vFrom and vTo are normalized - var v1, r; + var v1 = new Vector3(); + var r; var EPS = 0.000001;
false
Other
mrdoob
three.js
bece17cccaf55fd8f727bef023036fb74292132f.json
Improve Matrix4 closure performance
src/math/Matrix4.js
@@ -119,12 +119,10 @@ Object.assign( Matrix4.prototype, { extractRotation: function () { - var v1; + var v1 = new Vector3(); return function extractRotation( m ) { - if ( v1 === undefined ) v1 = new Vector3(); - var te = this.elements; var me = m.elements; @@ -317,18 +315,12 @@ Object.assign( Matrix4.prototype, { lookAt: function () { - var x, y, z; + var x = new Vector3(); + var y = new Vector3(); + var z = new Vector3(); return function lookAt( eye, target, up ) { - if ( x === undefined ) { - - x = new Vector3(); - y = new Vector3(); - z = new Vector3(); - - } - var te = this.elements; z.subVectors( eye, target ).normalize(); @@ -450,12 +442,10 @@ Object.assign( Matrix4.prototype, { applyToBufferAttribute: function () { - var v1; + var v1 = new Vector3(); return function applyToBufferAttribute( attribute ) { - if ( v1 === undefined ) v1 = new Vector3(); - for ( var i = 0, l = attribute.count; i < l; i ++ ) { v1.x = attribute.getX( i ); @@ -772,17 +762,11 @@ Object.assign( Matrix4.prototype, { decompose: function () { - var vector, matrix; + var vector = new Vector3(); + var matrix = new Matrix4(); return function decompose( position, quaternion, scale ) { - if ( vector === undefined ) { - - vector = new Vector3(); - matrix = new Matrix4(); - - } - var te = this.elements; var sx = vector.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
false
Other
mrdoob
three.js
2b46f6288c2c570c0eea2471d9c79deff2a06ffd.json
Improve Matrix3 closure performance
src/math/Matrix3.js
@@ -97,12 +97,10 @@ Object.assign( Matrix3.prototype, { applyToBufferAttribute: function () { - var v1; + var v1 = new Vector3(); return function applyToBufferAttribute( attribute ) { - if ( v1 === undefined ) v1 = new Vector3(); - for ( var i = 0, l = attribute.count; i < l; i ++ ) { v1.x = attribute.getX( i );
false
Other
mrdoob
three.js
e3eb4e545a009b6900f2392c445c606e420294df.json
Improve Euler closure performance
src/math/Euler.js
@@ -237,12 +237,10 @@ Object.assign( Euler.prototype, { setFromQuaternion: function () { - var matrix; + var matrix = new Matrix4(); return function setFromQuaternion( q, order, update ) { - if ( matrix === undefined ) matrix = new Matrix4(); - matrix.makeRotationFromQuaternion( q ); return this.setFromRotationMatrix( matrix, order, update );
false
Other
mrdoob
three.js
7ea7d9db8968e446fff6a92573a4685293b1be70.json
Improve Box3 closure performance
src/math/Box3.js
@@ -300,12 +300,10 @@ Object.assign( Box3.prototype, { intersectsSphere: ( function () { - var closestPoint; + var closestPoint = new Vector3(); return function intersectsSphere( sphere ) { - if ( closestPoint === undefined ) closestPoint = new Vector3(); - // Find the point on the AABB closest to the sphere center. this.clampPoint( sphere.center, closestPoint );
false
Other
mrdoob
three.js
bdef09a91e2aaadde02e62fea7bc3f78f0fbd52e.json
Improve Loader closure performance
src/loaders/Loader.js
@@ -108,14 +108,12 @@ Object.assign( Loader.prototype, { CustomBlending: CustomBlending }; - var color, textureLoader, materialLoader; + var color = new Color(); + var textureLoader = new TextureLoader(); + var materialLoader = new MaterialLoader(); return function createMaterial( m, texturePath, crossOrigin ) { - if ( color === undefined ) color = new Color(); - if ( textureLoader === undefined ) textureLoader = new TextureLoader(); - if ( materialLoader === undefined ) materialLoader = new MaterialLoader(); - // convert from old material format var textures = {};
false
Other
mrdoob
three.js
1be82538036931f87fb068f7d6fa85ea60681070.json
Improve BufferGeometry closure performance
src/core/BufferGeometry.js
@@ -166,12 +166,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { // rotate geometry around world x-axis - var m1; + var m1 = new Matrix4(); return function rotateX( angle ) { - if ( m1 === undefined ) m1 = new Matrix4(); - m1.makeRotationX( angle ); this.applyMatrix( m1 ); @@ -186,12 +184,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { // rotate geometry around world y-axis - var m1; + var m1 = new Matrix4(); return function rotateY( angle ) { - if ( m1 === undefined ) m1 = new Matrix4(); - m1.makeRotationY( angle ); this.applyMatrix( m1 ); @@ -206,12 +202,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { // rotate geometry around world z-axis - var m1; + var m1 = new Matrix4(); return function rotateZ( angle ) { - if ( m1 === undefined ) m1 = new Matrix4(); - m1.makeRotationZ( angle ); this.applyMatrix( m1 ); @@ -226,12 +220,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { // translate geometry - var m1; + var m1 = new Matrix4(); return function translate( x, y, z ) { - if ( m1 === undefined ) m1 = new Matrix4(); - m1.makeTranslation( x, y, z ); this.applyMatrix( m1 ); @@ -246,12 +238,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { // scale geometry - var m1; + var m1 = new Matrix4(); return function scale( x, y, z ) { - if ( m1 === undefined ) m1 = new Matrix4(); - m1.makeScale( x, y, z ); this.applyMatrix( m1 ); @@ -264,12 +254,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { lookAt: function () { - var obj; + var obj = new Object3D(); return function lookAt( vector ) { - if ( obj === undefined ) obj = new Object3D(); - obj.lookAt( vector ); obj.updateMatrix();
false
Other
mrdoob
three.js
9d3f35969330cb23b96220c1f9f2267a2b798141.json
Fix InterleavedBufferAttribute acessor assignement
src/core/InterleavedBufferAttribute.js
@@ -16,23 +16,19 @@ function InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, normal } -Object.assign( InterleavedBufferAttribute.prototype, { - - constructor: InterleavedBufferAttribute, +Object.defineProperties( InterleavedBufferAttribute.prototype, { - isInterleavedBufferAttribute: true, - - get count() { + "count" : { get: function () { return this.data.count; } }, - return this.data.count; + "array" : { get: function () { return this.data.array; } } - }, +} ); - get array() { +Object.assign( InterleavedBufferAttribute.prototype, { - return this.data.array; + constructor: InterleavedBufferAttribute, - }, + isInterleavedBufferAttribute: true, setX: function ( index, x ) {
false
Other
mrdoob
three.js
aa074e0869c2bb8233eeaaf3c03cf8ff0f863423.json
Move Vector3.applyProjection into Three.Legacy.js
src/Three.Legacy.js
@@ -570,6 +570,12 @@ Object.assign( Vector3.prototype, { console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' ); return this.setFromMatrixColumn( matrix, index ); + }, + applyProjection: function ( m ) { + + console.warn( 'THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.' ); + return this.applyMatrix4( m ); + } } );
true
Other
mrdoob
three.js
aa074e0869c2bb8233eeaaf3c03cf8ff0f863423.json
Move Vector3.applyProjection into Three.Legacy.js
src/math/Vector3.js
@@ -310,14 +310,6 @@ Vector3.prototype = { }, - applyProjection: function ( m ) { - - console.warn( 'THREE.Vector3: .applyProjection() is deprecated. Use .applyMatrix4( m ) instead.' ); - - return this.applyMatrix4( m ); - - }, - applyQuaternion: function ( q ) { var x = this.x, y = this.y, z = this.z;
true
Other
mrdoob
three.js
9d6f2d4ad2a7adbd61e060f494509afc6ff936af.json
Make applyMatrix4 branchless, clean up docs
docs/api/math/Vector3.html
@@ -108,9 +108,7 @@ <h3>[method:Vector3 applyMatrix3]( [page:Matrix3 m] )</h3> <h3>[method:Vector3 applyMatrix4]( [page:Matrix4 m] )</h3> <div> - [page:Matrix4 m] - [page:Matrix4] projection matrix.<br /><br /> - - Multiplies this vector and m, and divides by perspective. + Multiplies this vector (with an implicit 1 in the 4th dimension) and m, and divides by perspective. </div> <h3>[method:Vector3 applyQuaternion]( [page:Quaternion quaternion] )</h3>
true
Other
mrdoob
three.js
9d6f2d4ad2a7adbd61e060f494509afc6ff936af.json
Make applyMatrix4 branchless, clean up docs
src/math/Vector3.js
@@ -299,16 +299,12 @@ Vector3.prototype = { this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ]; this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ]; this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ]; - var w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ]; + var w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ]; - if ( w !== 1 ) { - - var d = 1 / w; // perspective divide - this.x *= d; - this.y *= d; - this.z *= d; - - } + var d = 1 / w; // perspective divide + this.x *= d; + this.y *= d; + this.z *= d; return this;
true
Other
mrdoob
three.js
643f292e9522a5031d4dcdfe6d2cfeaf0f31d008.json
Combine Vector3.applyMatrix4 and applyProjection
src/math/Vector3.js
@@ -293,32 +293,32 @@ Vector3.prototype = { applyMatrix4: function ( m ) { - // input: THREE.Matrix4 affine matrix - var x = this.x, y = this.y, z = this.z; var e = m.elements; this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ]; this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ]; this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ]; + var w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ]; + + if ( w !== 1 ) { + + var d = 1 / w; // perspective divide + this.x *= d; + this.y *= d; + this.z *= d; + + } return this; }, applyProjection: function ( m ) { - // input: THREE.Matrix4 projection matrix + console.warn( 'THREE.Vector3: .applyProjection() is deprecated. Use .applyMatrix4( m ) instead.' ); - var x = this.x, y = this.y, z = this.z; - var e = m.elements; - var d = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] ); // perspective divide - - this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * d; - this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * d; - this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * d; - - return this; + return this.applyMatrix4( m ); },
false
Other
mrdoob
three.js
d9ca12ad15fa6867745563d4e0908ab3e00ec019.json
Ignore npm-debug.log files
.gitignore
@@ -2,4 +2,5 @@ *.swp .project node_modules -.idea/ \ No newline at end of file +.idea/ +npm-debug.log
false
Other
mrdoob
three.js
ef27e7f1933fbdda8a30a9004ab4eee7f9c91127.json
Fix typo in GLTFLoader
examples/js/loaders/GLTFLoader.js
@@ -2049,7 +2049,7 @@ THREE.GLTFLoader = ( function () { } else { - console.warn( "WARNING: joint: ''" + jointId + "' could not be found" ); + console.warn( "WARNING: joint: '" + jointId + "' could not be found" ); }
false
Other
mrdoob
three.js
8583c8e13aba7afc8eae9dd838da74e2a8cd98e7.json
Fix typo in Skeleton
src/objects/Skeleton.js
@@ -64,7 +64,7 @@ function Skeleton( bones, boneInverses, useVertexTexture ) { } else { - console.warn( 'THREE.Skeleton bonInverses is the wrong length.' ); + console.warn( 'THREE.Skeleton boneInverses is the wrong length.' ); this.boneInverses = [];
false
Other
mrdoob
three.js
5a7837eb729f1481baadc454671dad933701faab.json
revert unwanted change
build/three.js
@@ -4781,7 +4781,7 @@ var n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS ); - for ( var i = 0; i < n; ++ i ) { + for ( var i = 0; i !== n; ++ i ) { var info = gl.getActiveUniform( program, i ), path = info.name,
true
Other
mrdoob
three.js
5a7837eb729f1481baadc454671dad933701faab.json
revert unwanted change
build/three.module.js
@@ -4775,7 +4775,7 @@ function WebGLUniforms( gl, program, renderer ) { var n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS ); - for ( var i = 0; i < n; ++ i ) { + for ( var i = 0; i !== n; ++ i ) { var info = gl.getActiveUniform( program, i ), path = info.name,
true
Other
mrdoob
three.js
5a7837eb729f1481baadc454671dad933701faab.json
revert unwanted change
src/renderers/webgl/WebGLUniforms.js
@@ -481,7 +481,7 @@ function WebGLUniforms( gl, program, renderer ) { var n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS ); - for ( var i = 0; i < n; ++ i ) { + for ( var i = 0; i !== n; ++ i ) { var info = gl.getActiveUniform( program, i ), path = info.name,
true
Other
mrdoob
three.js
9aab3c6b983a9876ee567c9370fb7987344ebcf1.json
Provide AnimationClip objects from GLTFLoader. Replaces GLTFLoader.Animations, GLTFAnimation and GLTFInterpolator, and adds support for AnimationMixer / AnimationAction controls.
examples/js/loaders/GLTFLoader.js
@@ -54,14 +54,14 @@ THREE.GLTFLoader = ( function () { } ); - parser.parse( function ( scene, cameras, animations ) { + parser.parse( function ( scene, cameras, clips ) { console.timeEnd( 'GLTFLoader' ); var glTF = { "scene": scene, "cameras": cameras, - "animations": animations + "clips": clips }; callback( glTF ); @@ -241,233 +241,66 @@ THREE.GLTFLoader = ( function () { }; - /* GLTFANIMATION */ + /* ANIMATION */ - GLTFLoader.Animations = new GLTFRegistry(); - - // Construction/initialization - function GLTFAnimation( interps ) { - - this.running = false; - this.loop = false; - this.duration = 0; - this.startTime = 0; - this.interps = []; - - this.uuid = THREE.Math.generateUUID(); - - if ( interps ) { - - this.createInterpolators( interps ); - - } - - } - - GLTFAnimation.prototype.createInterpolators = function ( interps ) { + function createClip( name, interps ) { + var tracks = []; for ( var i = 0, len = interps.length; i < len; i ++ ) { - var interp = new GLTFInterpolator( interps[ i ] ); - this.interps.push( interp ); - this.duration = Math.max( this.duration, interp.duration ); - - } - - }; - - // Start/stop - GLTFAnimation.prototype.play = function () { - - if ( this.running ) - return; - - this.startTime = Date.now(); - this.running = true; - GLTFLoader.Animations.add( this.uuid, this ); - - }; - - GLTFAnimation.prototype.stop = function () { - - this.running = false; - GLTFLoader.Animations.remove( this.uuid ); - - }; - - // Update - drive key frame evaluation - GLTFAnimation.prototype.update = function () { - - if ( ! this.running ) return; - - var now = Date.now(); - var deltat = ( now - this.startTime ) / 1000; - var t = deltat % this.duration; - var nCycles = Math.floor( deltat / this.duration ); - var interps = this.interps; - - if ( nCycles >= 1 && ! this.loop ) { - - this.running = false; - - for ( var i = 0, l = interps.length; i < l; i ++ ) { - - interps[ i ].interp( this.duration ); - - } - - this.stop(); - - } else { - - for ( var i = 0, l = interps.length; i < l; i ++ ) { - - interps[ i ].interp( t ); - - } - - } - - }; - - /* GLTFINTERPOLATOR */ - - function GLTFInterpolator( param ) { - - this.keys = param.keys; - this.values = param.values; - this.count = param.count; - this.type = param.type; - this.path = param.path; - this.isRot = false; - - var node = param.target; - node.updateMatrix(); - node.matrixAutoUpdate = true; - this.targetNode = node; - - switch ( param.path ) { - - case "translation" : - - this.target = node.position; - this.originalValue = node.position.clone(); - break; - - case "rotation" : + validateInterpolator( interps[ i ] ); - this.target = node.quaternion; - this.originalValue = node.quaternion.clone(); - this.isRot = true; - break; - - case "scale" : - - this.target = node.scale; - this.originalValue = node.scale.clone(); - break; + interps[ i ].target.updateMatrix(); + interps[ i ].target.matrixAutoUpdate = true; + tracks.push( new THREE.KeyframeTrack( + interps[ i ].name, + interps[ i ].times, + interps[ i ].values, + interps[ i ].type + ) ); } - this.duration = this.keys[ this.count - 1 ]; - - this.vec1 = new THREE.Vector3(); - this.vec2 = new THREE.Vector3(); - this.vec3 = new THREE.Vector3(); - this.quat1 = new THREE.Quaternion(); - this.quat2 = new THREE.Quaternion(); - this.quat3 = new THREE.Quaternion(); - + return new THREE.AnimationClip( name, undefined, tracks ); } - //Interpolation and tweening methods - GLTFInterpolator.prototype.interp = function ( t ) { - - if ( t == this.keys[ 0 ] ) { - - if ( this.isRot ) { - - this.quat3.fromArray( this.values ); - - } else { - - this.vec3.fromArray( this.values ); - - } - - } else if ( t < this.keys[ 0 ] ) { + /** + * Interp times are frequently non-sequential in the monster and cesium man + * models. That's probably a sign that the exporter is misbehaving, but to + * keep this backward-compatible we can swallow the errors. + */ + function validateInterpolator( interp ) { - if ( this.isRot ) { + var times = []; + var values = []; + var prevTime = null; + var currTime = null; - this.quat1.copy( this.originalValue ); - this.quat2.fromArray( this.values ); - THREE.Quaternion.slerp( this.quat1, this.quat2, this.quat3, t / this.keys[ 0 ] ); + var stride = interp.values.length / interp.times.length; - } else { - - this.vec3.copy( this.originalValue ); - this.vec2.fromArray( this.values ); - this.vec3.lerp( this.vec2, t / this.keys[ 0 ] ); - - } - - } else if ( t >= this.keys[ this.count - 1 ] ) { - - if ( this.isRot ) { - - this.quat3.fromArray( this.values, ( this.count - 1 ) * 4 ); + for ( var i = 0; i < interp.times.length; i ++ ) { - } else { - - this.vec3.fromArray( this.values, ( this.count - 1 ) * 3 ); - - } - - } else { + currTime = interp.times[ i ]; - for ( var i = 0; i < this.count - 1; i ++ ) { + if (prevTime !== null && prevTime <= currTime) { - var key1 = this.keys[ i ]; - var key2 = this.keys[ i + 1 ]; + times.push( currTime ); - if ( t >= key1 && t <= key2 ) { + for ( var j = 0; j < stride; j++ ) { - if ( this.isRot ) { - - this.quat1.fromArray( this.values, i * 4 ); - this.quat2.fromArray( this.values, ( i + 1 ) * 4 ); - THREE.Quaternion.slerp( this.quat1, this.quat2, this.quat3, ( t - key1 ) / ( key2 - key1 ) ); - - } else { - - this.vec3.fromArray( this.values, i * 3 ); - this.vec2.fromArray( this.values, ( i + 1 ) * 3 ); - this.vec3.lerp( this.vec2, ( t - key1 ) / ( key2 - key1 ) ); - - } + values.push( interp.values[ i * stride + j ] ); } } + prevTime = currTime; } - if ( this.target ) { - - if ( this.isRot ) { - - this.target.copy( this.quat3 ); - - } else { - - this.target.copy( this.vec3 ); - - } - - } - - }; + interp.times = new Float32Array( times ); + interp.values = new Float32Array( values ); + } /*********************************/ /********** INTERNALS ************/ @@ -539,6 +372,16 @@ THREE.GLTFLoader = ( function () { 'MAT4': 16 }; + var PATH_PROPERTIES = { + scale: 'scale', + translation: 'position', + rotation: 'quaternion' + }; + + var INTERPOLATION = { + LINEAR: THREE.InterpolateLinear + }; + /* UTILITY FUNCTIONS */ function _each( object, callback, thisObj ) { @@ -798,7 +641,7 @@ THREE.GLTFLoader = ( function () { "scenes", "cameras", - "animations" + "clips" ] ).then( function ( dependencies ) { @@ -813,16 +656,16 @@ THREE.GLTFLoader = ( function () { } - var animations = []; + var clips = []; - for ( var name in dependencies.animations ) { + for ( var name in dependencies.clips ) { - var animation = dependencies.animations[ name ]; - animations.push( animation ); + var clip = dependencies.clips[ name ]; + clips.push( clip ); } - callback( scene, cameras, animations ); + callback( scene, cameras, clips); }.bind( this ) ); @@ -1435,7 +1278,9 @@ THREE.GLTFLoader = ( function () { }; - GLTFParser.prototype.loadAnimations = function () { + + + GLTFParser.prototype.loadClips = function () { var scope = this; @@ -1470,12 +1315,11 @@ THREE.GLTFLoader = ( function () { if ( node ) { var interp = { - keys: inputAccessor.array, + times: inputAccessor.array, values: outputAccessor.array, - count: inputAccessor.count, target: node, - path: target.path, - type: sampler.interpolation + type: INTERPOLATION[ sampler.interpolation ], + name: node.name + '.' + PATH_PROPERTIES[ target.path ] }; interps.push( interp ); @@ -1486,10 +1330,7 @@ THREE.GLTFLoader = ( function () { } - var _animation = new GLTFAnimation( interps ); - _animation.name = "animation_" + animationId; - - return _animation; + return createClip( "animation_" + animationId, interps ); } );
true
Other
mrdoob
three.js
9aab3c6b983a9876ee567c9370fb7987344ebcf1.json
Provide AnimationClip objects from GLTFLoader. Replaces GLTFLoader.Animations, GLTFAnimation and GLTFInterpolator, and adds support for AnimationMixer / AnimationAction controls.
examples/webgl_loader_gltf.html
@@ -137,6 +137,8 @@ var cameraNames = []; var defaultCamera = null; var gltf = null; + var mixer = null; + var clock = new THREE.Clock(); function onload() { @@ -312,17 +314,18 @@ } - if (gltf.animations && gltf.animations.length) { + if (gltf.clips && gltf.clips.length) { - var i, len = gltf.animations.length; + mixer = new THREE.AnimationMixer(object); + + var i, len = gltf.clips.length; for (i = 0; i < len; i++) { - var animation = gltf.animations[i]; - animation.loop = true; + var clip = gltf.clips[i]; // There's .3333 seconds junk at the tail of the Monster animation that // keeps it from looping cleanly. Clip it at 3 seconds if (sceneInfo.animationTime) - animation.duration = sceneInfo.animationTime; - animation.play(); + clip.duration = sceneInfo.animationTime; + mixer.clipAction(clip).play(); } } @@ -353,7 +356,7 @@ function animate() { requestAnimationFrame( animate ); - THREE.GLTFLoader.Animations.update(); + if (mixer) mixer.update(clock.getDelta()); THREE.GLTFLoader.Shaders.update(scene, camera); if (cameraIndex == 0) orbitControls.update(); @@ -513,16 +516,17 @@ function toggleAnimations() { - var i, len = gltf.animations.length; + var i, len = gltf.clips.length; for (i = 0; i < len; i++) { - var animation = gltf.animations[i]; + var clip = gltf.clips[i]; + var action = mixer.existingAction( clip ); - if (animation.running) { - animation.stop(); + if (action.isRunning()) { + action.stop(); } else { - animation.play(); + action.play(); } } @@ -549,17 +553,10 @@ cameraNames = []; defaultCamera = null; - if (!loader || !gltf.animations) + if (!loader || !mixer) return; - var i, len = gltf.animations.length; - - for (i = 0; i < len; i++) { - var animation = gltf.animations[i]; - if (animation.running) { - animation.stop(); - } - } + mixer.stopAllAction(); }
true
Other
mrdoob
three.js
52836bac07ba318fbed18e918e78012ca6215d6b.json
fix unique node
examples/js/nodes/TempNode.js
@@ -49,6 +49,12 @@ THREE.TempNode.prototype.build = function( builder, output, uuid, ns ) { return THREE.GLNode.prototype.build.call( this, builder, output, uuid ); + } else if ( isUnique ) { + + data.name = data.name || THREE.GLNode.prototype.build.call( this, builder, output, uuid ) + + return data.name; + } else if ( ! builder.optimize || data.deps == 1 ) { return THREE.GLNode.prototype.build.call( this, builder, output, uuid );
false
Other
mrdoob
three.js
0d1e85694731632281bdc351ae33d4d2b55c89ac.json
fix auto transparency
examples/js/nodes/NodeMaterial.js
@@ -212,7 +212,7 @@ THREE.NodeMaterial.prototype.build = function() { } this.lights = this.requestAttribs.light; - this.transparent = this.requestAttribs.transparent || this.blendMode > THREE.NormalBlending; + this.transparent = this.requestAttribs.transparent || this.blending > THREE.NormalBlending; this.vertexShader = [ this.prefixCode,
false
Other
mrdoob
three.js
74cc4b17bb52a3238cca4dba8cafab656027a879.json
fix a space
examples/js/loaders/AssimpLoader.js
@@ -1871,7 +1871,9 @@ mesh.mIndexArray.push( f.mIndices[ 0 ] ); } else { + throw ( new Error( "Sorry, can't currently triangulate polys. Use the triangulate preprocessor in Assimp." )) + }
false
Other
mrdoob
three.js
a14d4d60eb4d7fcf9a20a23eeeff19a80dcce5bf.json
remove old loader
examples/js/loaders/ABINloader.js
@@ -1,2055 +0,0 @@ - -(function(){ - - -var Virtulous = {}; - - -Virtulous.KeyFrame = function( time, matrix ) { - - this.time = time; - this.matrix = matrix.clone(); - this.position = new THREE.Vector3(); - this.quaternion = new THREE.Quaternion(); - this.scale = new THREE.Vector3( 1, 1, 1 ); - this.matrix.decompose( this.position, this.quaternion, this.scale ); - this.clone = function() { - - var n = new Virtulous.KeyFrame( this.time, this.matrix ); - return n; - - } - this.lerp = function( nextKey, time ) { - - time -= this.time; - var dist = ( nextKey.time - this.time ); - var l = time / dist; - var l2 = 1 - l; - var keypos = this.position; - var keyrot = this.quaternion; - // var keyscl = key.parentspaceScl || key.scl; - var key2pos = nextKey.position; - var key2rot = nextKey.quaternion - // var key2scl = key2.parentspaceScl || key2.scl; - Virtulous.KeyFrame.tempAniPos.x = keypos.x * l2 + key2pos.x * l; - Virtulous.KeyFrame.tempAniPos.y = keypos.y * l2 + key2pos.y * l; - Virtulous.KeyFrame.tempAniPos.z = keypos.z * l2 + key2pos.z * l; - // tempAniScale.x = keyscl[0] * l2 + key2scl[0] * l; - // tempAniScale.y = keyscl[1] * l2 + key2scl[1] * l; - // tempAniScale.z = keyscl[2] * l2 + key2scl[2] * l; - Virtulous.KeyFrame.tempAniQuat.set( keyrot.x, keyrot.y, keyrot.z, keyrot.w ); - Virtulous.KeyFrame.tempAniQuat.slerp( key2rot, l ); - return Virtulous.KeyFrame.tempAniMatrix.compose( Virtulous.KeyFrame.tempAniPos, Virtulous.KeyFrame.tempAniQuat, Virtulous.KeyFrame.tempAniScale ); - - } - -} -Virtulous.KeyFrame.tempAniPos = new THREE.Vector3(); -Virtulous.KeyFrame.tempAniQuat = new THREE.Quaternion(); -Virtulous.KeyFrame.tempAniScale = new THREE.Vector3( 1, 1, 1 ); -Virtulous.KeyFrame.tempAniMatrix = new THREE.Matrix4(); -Virtulous.KeyFrameTrack = function() { - - this.keys = []; - this.target = null; - this.time = 0; - this.length = 0; - this._accelTable = {}; - this.fps = 20; - this.addKey = function( key ) { - - this.keys.push( key ); - - } - this.init = function() { - - this.sortKeys(); - if ( this.keys.length > 0 ) - this.length = this.keys[ this.keys.length - 1 ].time; - else - this.length = 0; - if ( !this.fps ) return; - for ( var j = 0; j < this.length * this.fps; j++ ) { - - for ( var i = 0; i < this.keys.length; i++ ) { - - if ( this.keys[ i ].time == j ) { - - this._accelTable[ j ] = i; - break; - } else if ( this.keys[ i ].time < j / this.fps && this.keys[ i + 1 ] && this.keys[ i + 1 ].time >= j / this.fps ) { - - this._accelTable[ j ] = i; - break; - - } - - } - - } - - } - this.parseFromThree = function( data ) { - - var fps = data.fps; - this.target = data.node; - var track = data.hierarchy[ 0 ].keys; - for ( var i = 0; i < track.length; i++ ) { - - this.addKey( new Virtulous.KeyFrame( i / fps || track[ i ].time, track[ i ].targets[ 0 ].data ) ) - - } - this.init(); - - } - this.parseFromCollada = function( data ) { - - var track = data.keys; - var fps = this.fps; - for ( var i = 0; i < track.length; i++ ) { - - this.addKey( new Virtulous.KeyFrame( i / fps || track[ i ].time, track[ i ].matrix ) ) - - } - this.init(); - - } - this.sortKeys = function() { - - this.keys.sort( this.keySortFunc ) - - } - this.keySortFunc = function( a, b ) { - - return a.time - b.time; - } - - this.clone = function() { - - var t = new Virtulous.KeyFrameTrack(); - t.target = this.target; - t.time = this.time; - t.length = this.length; - for ( var i = 0; i < this.keys.length; i++ ) { - - t.addKey( this.keys[ i ].clone() ); - } - - t.init(); - return t; - } - - this.reTarget = function( root, compareitor ) { - - if ( !compareitor ) compareitor = Virtulous.TrackTargetNodeNameCompare; - this.target = compareitor( root, this.target ); - - } - this.keySearchAccel = function( time ) { - - time *= this.fps; - time = Math.floor( time ); - return this._accelTable[ time ] || 0; - } - - this.setTime = function( time ) { - - time = Math.abs( time ); - if ( this.length ) - time = time % this.length + .05; - var key0 = null; - var key1 = null; - for ( var i = this.keySearchAccel( time ); i < this.keys.length; i++ ) { - - if ( this.keys[ i ].time == time ) { - - key0 = this.keys[ i ]; - key1 = this.keys[ i ]; - break; - - } else if ( this.keys[ i ].time < time && this.keys[ i + 1 ] && this.keys[ i + 1 ].time > time ) { - - key0 = this.keys[ i ]; - key1 = this.keys[ i + 1 ]; - break; - - } else if ( this.keys[ i ].time < time && i == this.keys.length - 1 ) { - - key0 = this.keys[ i ]; - key1 = this.keys[ 0 ].clone(); - key1.time += this.length + .05; - break; - - } - - } - if ( key0 && key1 && key0 !== key1 ) { - - this.target.matrixAutoUpdate = false; - this.target.matrix.copy( key0.lerp( key1, time ) ); - this.target.matrixWorldNeedsUpdate = true; - return; - - } - if ( key0 && key1 && key0 == key1 ) { - - this.target.matrixAutoUpdate = false; - this.target.matrix.copy( key0.matrix ); - this.target.matrixWorldNeedsUpdate = true; - return; - - } - } -} -Virtulous.TrackTargetNodeNameCompare = function( root, target ) { - - function find( node, name ) { - - if ( node.name == name ) - return node; - for ( var i = 0; i < node.children.length; i++ ) { - - var r = find( node.children[ i ], name ) - if ( r ) return r; - - } - - return null; - - } - - return find( root, target.name ); - -} -Virtulous.Animation = function() { - - this.tracks = []; - this.length = 0; - this.addTrack = function( track ) { - - this.tracks.push( track ); - this.length = Math.max( track.length, this.length ); - - } - this.setTime = function( time ) { - - this.time = time; - for ( var i = 0; i < this.tracks.length; i++ ) - this.tracks[ i ].setTime( time ); - - } - - this.clone = function( target, compareitor ) { - - if ( !compareitor ) compareitor = Virtulous.TrackTargetNodeNameCompare; - var n = new Virtulous.Animation(); - n.target = target; - for ( var i = 0; i < this.tracks.length; i++ ) { - - var track = this.tracks[ i ].clone(); - track.reTarget( target, compareitor ); - n.addTrack( track ); - - } - - return n; - - } - -} - -var ASSBIN_CHUNK_AICAMERA = 0x1234; -var ASSBIN_CHUNK_AILIGHT = 0x1235; -var ASSBIN_CHUNK_AITEXTURE = 0x1236; -var ASSBIN_CHUNK_AIMESH = 0x1237; -var ASSBIN_CHUNK_AINODEANIM = 0x1238; -var ASSBIN_CHUNK_AISCENE = 0x1239; -var ASSBIN_CHUNK_AIBONE = 0x123a; -var ASSBIN_CHUNK_AIANIMATION = 0x123b; -var ASSBIN_CHUNK_AINODE = 0x123c; -var ASSBIN_CHUNK_AIMATERIAL = 0x123d; -var ASSBIN_CHUNK_AIMATERIALPROPERTY = 0x123e; -var ASSBIN_MESH_HAS_POSITIONS = 0x1; -var ASSBIN_MESH_HAS_NORMALS = 0x2; -var ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS = 0x4; -var ASSBIN_MESH_HAS_TEXCOORD_BASE = 0x100; -var ASSBIN_MESH_HAS_COLOR_BASE = 0x10000; -var AI_MAX_NUMBER_OF_COLOR_SETS = 1; -var AI_MAX_NUMBER_OF_TEXTURECOORDS = 4; -var aiLightSource_UNDEFINED = 0x0; -//! A directional light source has a well-defined direction -//! but is infinitely far away. That's quite a good -//! approximation for sun light. -var aiLightSource_DIRECTIONAL = 0x1; -//! A point light source has a well-defined position -//! in space but no direction - it emits light in all -//! directions. A normal bulb is a point light. -var aiLightSource_POINT = 0x2; -//! A spot light source emits light in a specific -//! angle. It has a position and a direction it is pointing to. -//! A good example for a spot light is a light spot in -//! sport arenas. -var aiLightSource_SPOT = 0x3; -//! The generic light level of the world, including the bounces -//! of all other lightsources. -//! Typically, there's at most one ambient light in a scene. -//! This light type doesn't have a valid position, direction, or -//! other properties, just a color. -var aiLightSource_AMBIENT = 0x4; -/** Flat shading. Shading is done on per-face base, - * diffuse only. Also known as 'faceted shading'. - */ -var aiShadingMode_Flat = 0x1; -/** Simple Gouraud shading. - */ -var aiShadingMode_Gouraud = 0x2; -/** Phong-Shading - - */ -var aiShadingMode_Phong = 0x3; -/** Phong-Blinn-Shading - */ -var aiShadingMode_Blinn = 0x4; -/** Toon-Shading per pixel - * - * Also known as 'comic' shader. - */ -var aiShadingMode_Toon = 0x5; -/** OrenNayar-Shading per pixel - * - * Extension to standard Lambertian shading, taking the - * roughness of the material into account - */ -var aiShadingMode_OrenNayar = 0x6; -/** Minnaert-Shading per pixel - * - * Extension to standard Lambertian shading, taking the - * "darkness" of the material into account - */ -var aiShadingMode_Minnaert = 0x7; -/** CookTorrance-Shading per pixel - * - * Special shader for metallic surfaces. - */ -var aiShadingMode_CookTorrance = 0x8; -/** No shading at all. Constant light influence of 1.0. - */ -var aiShadingMode_NoShading = 0x9; -/** Fresnel shading - */ -var aiShadingMode_Fresnel = 0xa; -var aiTextureType_NONE = 0x0; -/** The texture is combined with the result of the diffuse - * lighting equation. - */ -var aiTextureType_DIFFUSE = 0x1; -/** The texture is combined with the result of the specular - * lighting equation. - */ -var aiTextureType_SPECULAR = 0x2; -/** The texture is combined with the result of the ambient - * lighting equation. - */ -var aiTextureType_AMBIENT = 0x3; -/** The texture is added to the result of the lighting - * calculation. It isn't influenced by incoming light. - */ -var aiTextureType_EMISSIVE = 0x4; -/** The texture is a height map. - * - * By convention, higher gray-scale values stand for - * higher elevations from the base height. - */ -var aiTextureType_HEIGHT = 0x5; -/** The texture is a (tangent space) normal-map. - * - * Again, there are several conventions for tangent-space - * normal maps. Assimp does (intentionally) not - * distinguish here. - */ -var aiTextureType_NORMALS = 0x6; -/** The texture defines the glossiness of the material. - * - * The glossiness is in fact the exponent of the specular - * (phong) lighting equation. Usually there is a conversion - * function defined to map the linear color values in the - * texture to a suitable exponent. Have fun. - */ -var aiTextureType_SHININESS = 0x7; -/** The texture defines per-pixel opacity. - * - * Usually 'white' means opaque and 'black' means - * 'transparency'. Or quite the opposite. Have fun. - */ -var aiTextureType_OPACITY = 0x8; -/** Displacement texture - * - * The exact purpose and format is application-dependent. - * Higher color values stand for higher vertex displacements. - */ -var aiTextureType_DISPLACEMENT = 0x9; -/** Lightmap texture (aka Ambient Occlusion) - * - * Both 'Lightmaps' and dedicated 'ambient occlusion maps' are - * covered by this material property. The texture contains a - * scaling value for the final color value of a pixel. Its - * intensity is not affected by incoming light. - */ -var aiTextureType_LIGHTMAP = 0xA; -/** Reflection texture - * - * Contains the color of a perfect mirror reflection. - * Rarely used, almost never for real-time applications. - */ -var aiTextureType_REFLECTION = 0xB; -/** Unknown texture - * - * A texture reference that does not match any of the definitions - * above is considered to be 'unknown'. It is still imported, - * but is excluded from any further postprocessing. - */ -var aiTextureType_UNKNOWN = 0xC; -var BONESPERVERT = 4; - -function ASSBIN_MESH_HAS_TEXCOORD( n ) { - - return ( ASSBIN_MESH_HAS_TEXCOORD_BASE << n ) - -} - -function ASSBIN_MESH_HAS_COLOR( n ) { - - return ( ASSBIN_MESH_HAS_COLOR_BASE << n ) - -} - -function markBones( scene ) { - - for ( var i in scene.mMeshes ) { - - var mesh = scene.mMeshes[ i ]; - for ( var k in mesh.mBones ) { - - var boneNode = scene.findNode( mesh.mBones[ k ].mName ); - if ( boneNode ) - boneNode.isBone = true; - - } - - } - -} -function cloneTreeToBones( root, scene ) { - - var rootBone = new THREE.Bone(); - rootBone.matrix.copy( root.matrix ); - rootBone.matrixWorld.copy( root.matrixWorld ); - rootBone.position.copy( root.position ); - rootBone.quaternion.copy( root.quaternion ); - rootBone.scale.copy( root.scale ); - scene.nodeCount++; - rootBone.name = "bone_" + root.name + scene.nodeCount.toString(); - - if ( !scene.nodeToBoneMap[ root.name ] ) - scene.nodeToBoneMap[ root.name ] = []; - scene.nodeToBoneMap[ root.name ].push( rootBone ); - for ( var i in root.children ) { - - var child = cloneTreeToBones( root.children[ i ], scene ); - if ( child ) - rootBone.add( child ); - - } - - return rootBone; - -} - -function aiAnimation() { - - this.mName = ""; - this.mDuration = 0; - this.mTicksPerSecond = 0; - this.mNumChannels = 0; - this.mChannels = []; - -} - -function sortWeights( indexes, weights ) { - - var pairs = []; - for ( var i = 0; i < indexes.length; i++ ) { - - pairs.push( { - - i: indexes[ i ], - w: weights[ i ] - } ) - } - pairs.sort( function( a, b ) { - - return b.w - a.w; - } ) - while ( pairs.length < 4 ) { - - pairs.push( { - - i: 0, - w: 0 - } ) - }; - if ( pairs.length > 4 ) - pairs.length = 4; - var sum = 0; - for ( var i = 0; i < 4; i++ ) { - - sum += pairs[ i ].w * pairs[ i ].w; - } - sum = Math.sqrt( sum ); - for ( var i = 0; i < 4; i++ ) { - - pairs[ i ].w = pairs[ i ].w / sum; - indexes[ i ] = pairs[ i ].i; - weights[ i ] = pairs[ i ].w; - } - -} - -function findMatchingBone( root, name ) { - - if ( root.name.indexOf( "bone_" + name ) == 0 ) - return root; - - for ( var i in root.children ) { - - var ret = findMatchingBone( root.children[ i ], name ) - if ( ret ) - return ret; - - } - - return undefined; - -} - -function aiMesh() { - - this.mPrimitiveTypes = 0; - this.mNumVertices = 0; - this.mNumFaces = 0; - this.mNumBones = 0; - this.mMaterialIndex = 0; - this.mVertices = []; - this.mNormals = []; - this.mTangents = []; - this.mBitangents = []; - this.mColors = [ - [] - ]; - this.mTextureCoords = [ - [] - ]; - this.mFaces = []; - this.mBones = []; - this.hookupSkeletons = function(scene, threeScene) - { - if (this.mBones.length == 0) return - var allBones = []; - var offsetMatrix = []; - var skeletonRoot = scene.findNode(this.mBones[0].mName); - - while (skeletonRoot.mParent && skeletonRoot.mParent.isBone) - { - skeletonRoot = skeletonRoot.mParent; - } - var threeSkeletonRoot = skeletonRoot.toTHREE(scene); - var threeSkeletonRootBone = cloneTreeToBones(threeSkeletonRoot,scene); - this.threeNode.add(threeSkeletonRootBone); - for (var i = 0; i < this.mBones.length; i++) - { - var bone = findMatchingBone(threeSkeletonRootBone, this.mBones[i].mName); - if (bone) - { - var tbone = bone; - allBones.push(tbone); - //tbone.matrixAutoUpdate = false; - offsetMatrix.push(this.mBones[i].mOffsetMatrix.toTHREE()); - } - else - { - var skeletonRoot = scene.findNode(this.mBones[i].mName); - if (!skeletonRoot) return; - var threeSkeletonRoot = skeletonRoot.toTHREE(scene); - var threeSkeletonRootParent = threeSkeletonRoot.parent; - var threeSkeletonRootBone = cloneTreeToBones(threeSkeletonRoot,scene); - this.threeNode.add(threeSkeletonRootBone); - var bone = findMatchingBone(threeSkeletonRootBone, this.mBones[i].mName); - var tbone = bone; - allBones.push(tbone); - //tbone.matrixAutoUpdate = false; - offsetMatrix.push(this.mBones[i].mOffsetMatrix.toTHREE()); - } - } - var skeleton = new THREE.Skeleton(allBones, offsetMatrix); - this.threeNode.bind(skeleton, new THREE.Matrix4()); - this.threeNode.material.skinning = true; - } - this.toTHREE = function( scene ) { - - if ( this.threeNode ) return this.threeNode; - var geometry = new THREE.BufferGeometry(); - var mat; - if ( scene.mMaterials[ this.mMaterialIndex ] ) - mat = scene.mMaterials[ this.mMaterialIndex ].toTHREE( scene ); - else - mat = new THREE.MeshLambertMaterial(); - geometry.addAttribute( 'position', new THREE.BufferAttribute( this.mVertexBuffer, 3 ) ); - geometry.setIndex(new THREE.BufferAttribute( new Uint32Array( this.mIndexArray ), 1 ) ); - if ( this.mNormalBuffer.length > 0 ) - geometry.addAttribute( 'normal', new THREE.BufferAttribute( this.mNormalBuffer, 3 ) ); - if ( this.mColorBuffer && this.mColorBuffer.length > 0 ) - geometry.addAttribute( 'color', new THREE.BufferAttribute( this.mColorBuffer, 4 ) ); - if ( this.mTexCoordsBuffers[ 0 ] && this.mTexCoordsBuffers[ 0 ].length > 0 ) - geometry.addAttribute( 'uv', new THREE.BufferAttribute( new Float32Array( this.mTexCoordsBuffers[ 0 ] ), 2 ) ); - if ( this.mTexCoordsBuffers[ 1 ] && this.mTexCoordsBuffers[ 1 ] && this.mTextureCoords[ 1 ].length > 0 ) - geometry.addAttribute( 'uv1', new THREE.BufferAttribute( new Float32Array( this.mTexCoordsBuffers[ 1 ] ), 2 ) ); - if ( this.mTangentBuffer && this.mTangentBuffer.length > 0 ) - geometry.addAttribute( 'tangents', new THREE.BufferAttribute( this.mTangentBuffer, 3 ) ); - if ( this.mBitangentBuffer && this.mBitangentBuffer.length > 0 ) - geometry.addAttribute( 'bitangents', new THREE.BufferAttribute( this.mBitangentBuffer, 3 ) ); - if ( this.mBones.length > 0 ) { - - var weights = []; - var bones = []; - for ( var i = 0 ; i < this.mBones.length; i++ ) { - - for ( var j = 0; j < this.mBones[ i ].mWeights.length; j++ ) { - - var weight = this.mBones[ i ].mWeights[ j ]; - if ( weight ) { - - if ( !weights[ weight.mVertexId ] ) weights[ weight.mVertexId ] = []; - if ( !bones[ weight.mVertexId ] ) bones[ weight.mVertexId ] = []; - weights[ weight.mVertexId ].push( weight.mWeight ); - bones[ weight.mVertexId ].push( parseInt( i ) ); - } - } - } - for ( var i in bones ) { - - sortWeights( bones[ i ], weights[ i ] ); - } - var _weights = []; - var _bones = []; - for ( var i = 0; i < weights.length; i++ ) - for ( var j = 0; j < 4; j++ ) { - - if ( weights[ i ] && bones[ i ] ) { - - _weights.push( weights[ i ][ j ] ); - _bones.push( bones[ i ][ j ] ); - } else { - - _weights.push( 0 ); - _bones.push( 0 ); - } - } - geometry.addAttribute( 'skinWeight', new THREE.BufferAttribute( new Float32Array( _weights ), BONESPERVERT ) ); - geometry.addAttribute( 'skinIndex', new THREE.BufferAttribute( new Float32Array( _bones ), BONESPERVERT ) ); - } - var mesh; - if ( this.mBones.length == 0 ) - mesh = new THREE.Mesh( geometry, mat ); - if ( this.mBones.length > 0 ) { - - mesh = new THREE.SkinnedMesh( geometry, mat ); - } - this.threeNode = mesh; - //mesh.matrixAutoUpdate = false; - return mesh; - } - -} - -function aiFace() { - - this.mNumIndices = 0; - this.mIndices = []; - -} - -function aiVector3D() { - - this.x = 0; - this.y = 0; - this.z = 0; - this.toTHREE = function() { - - return new THREE.Vector3( this.x, this.y, this.z ); - } - -} - -function aiVector2D() { - - this.x = 0; - this.y = 0; - this.toTHREE = function() { - - return new THREE.Vector2( this.x, this.y ); - } - -} - -function aiVector4D() { - - this.w = 0; - this.x = 0; - this.y = 0; - this.z = 0; - this.toTHREE = function() { - - return new THREE.Vector4( this.w, this.x, this.y, this.z ); - } - -} - -function aiColor4D() { - - this.r = 0; - this.g = 0; - this.b = 0; - this.a = 0; - this.toTHREE = function() { - - return new THREE.Color( this.r, this.g, this.b, this.a ); - } - -} - -function aiColor3D() { - - this.r = 0; - this.g = 0; - this.b = 0; - this.a = 0; - this.toTHREE = function() { - - return new THREE.Color( this.r, this.g, this.b, 1 ); - } - -} - -function aiQuaternion() -{ - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 0; - this.toTHREE = function() - { - - return new THREE.Quaternion(this.x, this.y, this.z, this.w); - } -} - -function aiVertexWeight() { - - this.mVertexId = 0; - this.mWeight = 0; - -} - -function aiString() { - - this.data = []; - this.toString = function() { - - var str = ''; - this.data.forEach( function( i ) { - - str += ( String.fromCharCode( i ) ) - } ); - return str.replace( /[^\x20-\x7E]+/g, '' ); - } - -} - -function aiVectorKey() { - - this.mTime = 0; - this.mValue = null; - -} - -function aiQuatKey() { - - this.mTime = 0; - this.mValue = null; - -} - -function aiNode() { - - this.mName = ''; - this.mTransformation = []; - this.mNumChildren = 0; - this.mNumMeshes = 0; - this.mMeshes = []; - this.mChildren = []; - this.toTHREE = function( scene ) { - - if ( this.threeNode ) return this.threeNode; - var o = new THREE.Object3D(); - o.name = this.mName; - o.matrix = this.mTransformation.toTHREE(); - for ( var i = 0; i < this.mChildren.length; i++ ) { - - o.add( this.mChildren[ i ].toTHREE( scene ) ); - } - for ( var i = 0; i < this.mMeshes.length; i++ ) { - - o.add( scene.mMeshes[ this.mMeshes[ i ] ].toTHREE( scene ) ); - } - this.threeNode = o; - //o.matrixAutoUpdate = false; - o.matrix.decompose( o.position, o.quaternion, o.scale ); - return o; - } - -} - -function aiBone() { - - this.mName = ''; - this.mNumWeights = 0; - this.mOffsetMatrix = 0; - -} - -function aiMaterialProperty() { - - this.mKey = ""; - this.mSemantic = 0; - this.mIndex = 0; - this.mData = []; - this.mDataLength = 0; - this.mType = 0; - this.dataAsColor = function() { - - var array = ( new Uint8Array( this.mData ) ).buffer; - var reader = new DataView( array ); - var r = reader.getFloat32( 0, true ); - var g = reader.getFloat32( 4, true ); - var b = reader.getFloat32( 8, true ); - //var a = reader.getFloat32(12, true); - return new THREE.Color( r, g, b ); - } - this.dataAsFloat = function() { - - var array = ( new Uint8Array( this.mData ) ).buffer; - var reader = new DataView( array ); - var r = reader.getFloat32( 0, true ); - return r; - } - this.dataAsBool = function() { - - var array = ( new Uint8Array( this.mData ) ).buffer; - var reader = new DataView( array ); - var r = reader.getFloat32( 0, true ); - return !!r; - } - this.dataAsString = function() { - - var s = new aiString(); - s.data = this.mData; - return s.toString(); - } - this.dataAsMap = function( scene ) { - - var baseURL = scene.baseURL; - baseURL = baseURL.substr(0, baseURL.lastIndexOf( "/" ) + 1 ) - var s = new aiString(); - s.data = this.mData; - var path = s.toString(); - path = path.replace( /\\/g, '/' ); - if ( path.indexOf( "/" ) != -1 ) { - - path = path.substr( path.lastIndexOf( "/" ) + 1 ); - } - - return THREE.ImageUtils.loadTexture(baseURL + path ); - } - -} -var namePropMapping = { - - "?mat.name": "name", - "$mat.shadingm": "shading", - "$mat.twosided": "twoSided", - "$mat.wireframe": "wireframe", - "$clr.ambient": "ambient", - "$clr.diffuse": "color", - "$clr.specular": "specular", - "$clr.emissive": "emissive", - "$clr.transparent": "transparent", - "$clr.reflective": "reflect", - "$mat.shininess": "shininess", - "$mat.reflectivity": "reflectivity", - "$mat.refracti": "refraction", - "$tex.file": "map" - -} -var nameTexMapping = { - - "$tex.ambient": "ambientMap", - "$clr.diffuse": "map", - "$clr.specular": "specMap", - "$clr.emissive": "emissive", - "$clr.transparent": "alphaMap", - "$clr.reflective": "reflectMap", - -} -var nameTypeMapping = { - - "?mat.name": "string", - "$mat.shadingm": "bool", - "$mat.twosided": "bool", - "$mat.wireframe": "bool", - "$clr.ambient": "color", - "$clr.diffuse": "color", - "$clr.specular": "color", - "$clr.emissive": "color", - "$clr.transparent": "color", - "$clr.reflective": "color", - "$mat.shininess": "float", - "$mat.reflectivity": "float", - "$mat.refracti": "float", - "$tex.file": "map" - -} - -function aiMaterial() { - - this.mNumAllocated = 0; - this.mNumProperties = 0; - this.mProperties = []; - this.toTHREE = function( scene ) { - - var name = this.mProperties[ 0 ].dataAsString(); - var mat = new THREE.MeshPhongMaterial(); - for ( var i = 0; i < this.mProperties.length; i++ ) { - - - if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'float' ) - mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsFloat(); - if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'color' ) - mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsColor(); - if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'bool' ) - mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsBool(); - if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'string' ) - mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsString(); - if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'map' ) { - - var prop = this.mProperties[ i ]; - if ( prop.mSemantic == aiTextureType_DIFFUSE ) - mat.map = this.mProperties[ i ].dataAsMap( scene ); - if ( prop.mSemantic == aiTextureType_NORMALS ) - mat.normalMap = this.mProperties[ i ].dataAsMap( scene ); - if ( prop.mSemantic == aiTextureType_LIGHTMAP ) - mat.lightMap = this.mProperties[ i ].dataAsMap( scene ); - if ( prop.mSemantic == aiTextureType_OPACITY ) - mat.alphaMap = this.mProperties[ i ].dataAsMap( scene ); - } - } - mat.ambient.r = .53; - mat.ambient.g = .53; - mat.ambient.b = .53; - mat.color.r = 1; - mat.color.g = 1; - mat.color.b = 1; - return mat; - } - -} - - -function veclerp(v1,v2,l) { - - var v = new THREE.Vector3(); - var lm1 = 1-l; - v.x = v1.x * l + v2.x * lm1; - v.y = v1.y * l + v2.y * lm1; - v.z = v1.z * l + v2.z * lm1; - return v; - -} - -function quatlerp(q1,q2,l) { - - return q1.clone().slerp(q2,1-l); - -} - -function sampleTrack(keys,time,lne,lerp) { - - if(keys.length == 1) - return keys[0].mValue.toTHREE(); - var dist = Infinity; - var key = null; - var nextKey = null; - - for(var i=0; i < keys.length; i++) - { - var timeDist = Math.abs(keys[i].mTime - time); - if( timeDist < dist && keys[i].mTime <= time) { - - dist = timeDist; - key = keys[i]; - nextKey = keys[i+1]; - - } - - } - if(!key) - return null; - if(key && nextKey) { - - var dT = nextKey.mTime - key.mTime; - var T = key.mTime - time; - var l = T/dT; - return lerp(key.mValue.toTHREE(),nextKey.mValue.toTHREE(),l) - - } - - nextKey = keys[0].clone(); - nextKey.mTime += lne; - var dT = nextKey.mTime - key.mTime; - var T = key.mTime - time; - var l = T/dT; - return lerp(key.mValue.toTHREE(),nextKey.mValue.toTHREE(),l) - -} - -function aiNodeAnim() { - this.mNodeName = ""; - this.mNumPositionKeys = 0; - this.mNumRotationKeys = 0; - this.mNumScalingKeys = 0; - this.mPositionKeys = []; - this.mRotationKeys = []; - this.mScalingKeys = []; - this.mPreState = ""; - this.mPostState = ""; - this.init = function(tps) { - - if(!tps) - tps = 1; - function t(t) { - - t.mTime /= tps; - } - this.mPositionKeys.forEach(t); - this.mRotationKeys.forEach(t); - this.mScalingKeys.forEach(t); - - } - this.sortKeys = function() { - - function comp(a,b) { - - return a.mTime - b.mTime; - - } - this.mPositionKeys.sort(comp); - this.mRotationKeys.sort(comp); - this.mScalingKeys.sort(comp); - - } - this.getLength = function() { - - return Math.max( - Math.max.apply(null,this.mPositionKeys.map(function(a){return a.mTime;})), - Math.max.apply(null,this.mRotationKeys.map(function(a){return a.mTime;})), - Math.max.apply(null,this.mScalingKeys.map(function(a){return a.mTime;})) - ) - - } - this.toTHREE = function(o,tps) { - - this.sortKeys(); - var length = this.getLength(); - var track = new Virtulous.KeyFrameTrack(); - - - for(var i = 0; i < length; i+=.05) - { - var matrix = new THREE.Matrix4(); - var time = i; - var pos = sampleTrack(this.mPositionKeys,time,length,veclerp); - var scale = sampleTrack(this.mScalingKeys,time,length,veclerp); - var rotation = sampleTrack(this.mRotationKeys,time,length,quatlerp); - matrix.compose(pos,rotation,scale); - var key = new Virtulous.KeyFrame(time,matrix); - track.addKey(key); - } - track.target = o.findNode(this.mNodeName).toTHREE(); - var tracks = [track]; - if( o.nodeToBoneMap[this.mNodeName]) - { - for(var i=0; i < o.nodeToBoneMap[this.mNodeName].length; i++) - { - var t2 = track.clone(); - t2.target = o.nodeToBoneMap[this.mNodeName][i]; - tracks.push(t2); - } - } - - return tracks; - } -} - - -function aiAnimation() { - - this.mName = ""; - this.mDuration = 0; - this.mTicksPerSecond = 0; - this.mNumChannels = 0; - this.mChannels = []; - this.toTHREE = function(root) { - - var animationHandle = new Virtulous.Animation(); - for(var i in this.mChannels) { - - this.mChannels[i].init(this.mTicksPerSecond) - var tracks = this.mChannels[i].toTHREE(root); - for(var j in tracks) - { - tracks[j].init(); - animationHandle.addTrack(tracks[j]); - } - - } - animationHandle.length = Math.max.apply(null,animationHandle.tracks.map(function(e){return e.length})); - return animationHandle; - - } - -} - -function aiTexture() { - - this.mWidth = 0; - this.mHeight = 0; - this.texAchFormatHint = []; - this.pcData = []; - -} - -function aiLight() { - - this.mName = ''; - this.mType = 0; - this.mAttenuationConstant = 0; - this.mAttenuationLinear = 0; - this.mAttenuationQuadratic = 0; - this.mAngleInnerCone = 0; - this.mAngleOuterCone = 0; - this.mColorDiffuse = null; - this.mColorSpecular = null; - this.mColorAmbient = null; - -} - -function aiCamera() { - - this.mName = ''; - this.mPosition = null; - this.mLookAt = null; - this.mUp = null; - this.mHorizontalFOV = 0; - this.mClipPlaneNear = 0; - this.mClipPlaneFar = 0; - this.mAspect = 0; - -} - -function aiScene() { - - this.mFlags = 0; - this.mNumMeshes = 0; - this.mNumMaterials = 0; - this.mNumAnimations = 0; - this.mNumTextures = 0; - this.mNumLights = 0; - this.mNumCameras = 0; - this.mRootNode = null; - this.mMeshes = []; - this.mMaterials = []; - this.mAnimations = []; - this.mLights = []; - this.mCameras = []; - this.nodeToBoneMap = {}; - this.findNode = function( name, root ) { - - if ( !root ) { - - root = this.mRootNode; - } - if ( root.mName == name ) { - - return root; - } - for ( var i = 0; i < root.mChildren.length; i++ ) { - - var ret = this.findNode( name, root.mChildren[ i ] ) - if ( ret ) return ret; - } - return null; - } - this.toTHREE = function() - { - this.nodeCount = 0; - markBones(this); - var o = this.mRootNode.toTHREE(this); - - for (var i in this.mMeshes) - this.mMeshes[i].hookupSkeletons(this, o); - if(this.mAnimations.length > 0) - { - var a = this.mAnimations[0].toTHREE(this); - } - return {object:o,animation:a}; - } - -} - -function aiMatrix4() { - - this.elements = [ - [], - [], - [], - [] - ]; - this.toTHREE = function() { - - var m = new THREE.Matrix4(); - for ( var i = 0; i < 4; ++i ) { - - for ( var i2 = 0; i2 < 4; ++i2 ) { - - m.elements[ i * 4 + i2 ] = this.elements[ i2 ][ i ] - } - } - return m; - } - -} -var littleEndian = true; - -function readFloat( dataview ) { - - var val = dataview.getFloat32( dataview.readOffset, littleEndian ); - dataview.readOffset += 4; - return val; - -} - -function Read_double( dataview ) { - - var val = dataview.getFloat64( dataview.readOffset, littleEndian ); - dataview.readOffset += 8; - return val; - -} - -function Read_uint8_t( dataview ) { - - var val = dataview.getUint8( dataview.readOffset ); - dataview.readOffset += 1; - return val; - -} - -function Read_uint16_t( dataview ) { - - var val = dataview.getUint16( dataview.readOffset, littleEndian ); - dataview.readOffset += 2; - return val; - -} - -function Read_unsigned_int( dataview ) { - - var val = dataview.getUint32( dataview.readOffset, littleEndian ); - dataview.readOffset += 4; - return val; - -} - -function Read_uint32_t( dataview ) { - - var val = dataview.getUint32( dataview.readOffset, littleEndian ); - dataview.readOffset += 4; - return val; - -} - -function Read_aiVector3D( stream ) { - - v = new aiVector3D(); - v.x = readFloat( stream ); - v.y = readFloat( stream ); - v.z = readFloat( stream ); - return v; - -} - -function Read_aiVector2D( stream ) { - - v = new aiVector2D(); - v.x = readFloat( stream ); - v.y = readFloat( stream ); - return v; - -} - -function Read_aiVector4D( stream ) { - - v = new aiVector4D(); - v.w = readFloat( stream ); - v.x = readFloat( stream ); - v.y = readFloat( stream ); - v.z = readFloat( stream ); - return v; - -} - -function Read_aiColor3D( stream ) { - - var c = new aiColor3D(); - c.r = readFloat( stream ); - c.g = readFloat( stream ); - c.b = readFloat( stream ); - return c; - -} - -function Read_aiColor4D( stream ) { - - var c = new aiColor4D(); - c.r = readFloat( stream ); - c.g = readFloat( stream ); - c.b = readFloat( stream ); - c.a = readFloat( stream ); - return c; - -} - -function Read_aiQuaternion( stream ) { - - var v = new aiQuaternion(); - v.w = readFloat( stream ); - v.x = readFloat( stream ); - v.y = readFloat( stream ); - v.z = readFloat( stream ); - return v; - -} - -function Read_aiString( stream ) { - - var s = new aiString(); - var stringlengthbytes = Read_unsigned_int( stream ); - stream.ReadBytes( s.data, 1, stringlengthbytes ); - return s.toString(); - -} - -function Read_aiVertexWeight( stream ) { - - var w = new aiVertexWeight(); - w.mVertexId = Read_unsigned_int( stream ); - w.mWeight = readFloat( stream ); - return w; - -} - -function Read_aiMatrix4x4( stream ) { - - var m = new aiMatrix4(); - for ( var i = 0; i < 4; ++i ) { - - for ( var i2 = 0; i2 < 4; ++i2 ) { - - m.elements[ i ][ i2 ] = readFloat( stream ); - } - } - return m; - -} - -function Read_aiVectorKey( stream ) { - - var v = new aiVectorKey(); - v.mTime = Read_double( stream ); - v.mValue = Read_aiVector3D( stream ); - return v; - -} - -function Read_aiQuatKey( stream ) { - - var v = new aiQuatKey(); - v.mTime = Read_double( stream ); - v.mValue = Read_aiQuaternion( stream ); - return v; - -} - -function ReadArray( stream, data, size ) { - - for ( var i = 0; i < size; i++ ) data[ i ] = Read( stream ); - -} - -function ReadArray_aiVector2D( stream, data, size ) { - - for ( var i = 0; i < size; i++ ) data[ i ] = Read_aiVector2D( stream ); - -} - -function ReadArray_aiVector3D( stream, data, size ) { - - for ( var i = 0; i < size; i++ ) data[ i ] = Read_aiVector3D( stream ); - -} - -function ReadArray_aiVector4D( stream, data, size ) { - - for ( var i = 0; i < size; i++ ) data[ i ] = Read_aiVector4D( stream ); - -} - -function ReadArray_aiVertexWeight( stream, data, size ) { - - for ( var i = 0; i < size; i++ ) data[ i ] = Read_aiVertexWeight( stream ); - -} - -function ReadArray_aiColor4D( stream, data, size ) { - - for ( var i = 0; i < size; i++ ) data[ i ] = Read_aiColor4D( stream ); - -} - -function ReadArray_aiVectorKey( stream, data, size ) { - - for ( var i = 0; i < size; i++ ) data[ i ] = Read_aiVectorKey( stream ); - -} - -function ReadArray_aiQuatKey( stream, data, size ) { - - for ( var i = 0; i < size; i++ ) data[ i ] = Read_aiQuatKey( stream ); - -} - -function ReadBounds( stream, T /*p*/ , n ) { - - // not sure what to do here, the data isn't really useful. - return stream.Seek( sizeof( T ) * n, aiOrigin_CUR ); - -} - -function ai_assert( bool ) { - - if ( !bool ) - throw ( "asset failed" ); - -} - -function ReadBinaryNode( stream, parent, depth ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AINODE ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - var node = new aiNode(); - node.mParent = parent; - node.mDepth = depth; - node.mName = Read_aiString( stream ); - node.mTransformation = Read_aiMatrix4x4( stream ); - node.mNumChildren = Read_unsigned_int( stream ); - node.mNumMeshes = Read_unsigned_int( stream ); - if ( node.mNumMeshes ) { - - node.mMeshes = [] - for ( var i = 0; i < node.mNumMeshes; ++i ) { - - node.mMeshes[ i ] = Read_unsigned_int( stream ); - } - } - if ( node.mNumChildren ) { - - node.mChildren = []; - for ( var i = 0; i < node.mNumChildren; ++i ) { - - var node2 = ReadBinaryNode( stream, node, depth++ ); - node.mChildren[ i ] = node2; - } - } - return node; - -} -// ----------------------------------------------------------------------------------- -function ReadBinaryBone( stream, b ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AIBONE ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - b.mName = Read_aiString( stream ); - b.mNumWeights = Read_unsigned_int( stream ); - b.mOffsetMatrix = Read_aiMatrix4x4( stream ); - // for the moment we write dumb min/max values for the bones, too. - // maybe I'll add a better, hash-like solution later - if ( shortened ) { - - ReadBounds( stream, b.mWeights, b.mNumWeights ); - } // else write as usual - else { - - b.mWeights = []; - ReadArray_aiVertexWeight( stream, b.mWeights, b.mNumWeights ); - } - return b; - -} - -function ReadBinaryMesh( stream, mesh ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AIMESH ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - mesh.mPrimitiveTypes = Read_unsigned_int( stream ); - mesh.mNumVertices = Read_unsigned_int( stream ); - mesh.mNumFaces = Read_unsigned_int( stream ); - mesh.mNumBones = Read_unsigned_int( stream ); - mesh.mMaterialIndex = Read_unsigned_int( stream ); - mesh.mNumUVComponents = []; - // first of all, write bits for all existent vertex components - var c = Read_unsigned_int( stream ); - if ( c & ASSBIN_MESH_HAS_POSITIONS ) { - - if ( shortened ) { - - ReadBounds( stream, mesh.mVertices, mesh.mNumVertices ); - } // else write as usual - else { - - mesh.mVertices = []; - mesh.mVertexBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 ); - stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR ); - } - } - if ( c & ASSBIN_MESH_HAS_NORMALS ) { - - if ( shortened ) { - - ReadBounds( stream, mesh.mNormals, mesh.mNumVertices ); - } // else write as usual - else { - - mesh.mNormals = []; - mesh.mNormalBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 ); - stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR ); - } - } - if ( c & ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS ) { - - if ( shortened ) { - - ReadBounds( stream, mesh.mTangents, mesh.mNumVertices ); - ReadBounds( stream, mesh.mBitangents, mesh.mNumVertices ); - } // else write as usual - else { - - mesh.mTangents = []; - mesh.mTangentBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 ); - stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR ); - mesh.mBitangents = []; - mesh.mBitangentBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 ); - stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR ); - } - } - for ( var n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS; ++n ) { - - if ( !( c & ASSBIN_MESH_HAS_COLOR( n ) ) ) - break; - if ( shortened ) { - - ReadBounds( stream, mesh.mColors[ n ], mesh.mNumVertices ); - } // else write as usual - else { - - mesh.mColors[ n ] = []; - mesh.mColorBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 4 * 4 ); - stream.Seek( mesh.mNumVertices * 4 * 4, aiOrigin_CUR ); - } - } - mesh.mTexCoordsBuffers = []; - for ( var n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++n ) { - - if ( !( c & ASSBIN_MESH_HAS_TEXCOORD( n ) ) ) - break; - // write number of UV components - mesh.mNumUVComponents[ n ] = Read_unsigned_int( stream ); - if ( shortened ) { - - ReadBounds( stream, mesh.mTextureCoords[ n ], mesh.mNumVertices ); - } // else write as usual - else { - - mesh.mTextureCoords[ n ] = []; - //note that assbin always writes 3d texcoords - mesh.mTexCoordsBuffers[ n ] = []; - for ( var uv = 0; uv < mesh.mNumVertices; uv++ ) { - - mesh.mTexCoordsBuffers[ n ].push( readFloat( stream ) ) - mesh.mTexCoordsBuffers[ n ].push( readFloat( stream ) ) - readFloat( stream ) - } - } - } - // write faces. There are no floating-point calculations involved - // in these, so we can write a simple hash over the face data - // to the dump file. We generate a single 32 Bit hash for 512 faces - // using Assimp's standard hashing function. - if ( shortened ) { - - Read_unsigned_int( stream ); - } else // else write as usual - { - - // if there are less than 2^16 vertices, we can simply use 16 bit integers ... - mesh.mFaces = []; - var indexCounter = 0; - mesh.mIndexArray = []; - for ( var i = 0; i < mesh.mNumFaces; ++i ) { - - var f = mesh.mFaces[ i ] = new aiFace(); - // BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff); - f.mNumIndices = Read_uint16_t( stream ); - f.mIndices = []; - for ( var a = 0; a < f.mNumIndices; ++a ) { - - if ( mesh.mNumVertices < ( 1 << 16 ) ) { - - f.mIndices[ a ] = Read_uint16_t( stream ); - } else { - - f.mIndices[ a ] = Read_unsigned_int( stream ); - } - mesh.mIndexArray.push( f.mIndices[ a ] ); - } - } - } - // write bones - if ( mesh.mNumBones ) { - - mesh.mBones = []; - for ( var a = 0; a < mesh.mNumBones; ++a ) { - - mesh.mBones[ a ] = new aiBone(); - ReadBinaryBone( stream, mesh.mBones[ a ] ); - } - } - -} - - - -function ReadBinaryMaterialProperty( stream, prop ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AIMATERIALPROPERTY ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - prop.mKey = Read_aiString( stream ); - prop.mSemantic = Read_unsigned_int( stream ); - prop.mIndex = Read_unsigned_int( stream ); - prop.mDataLength = Read_unsigned_int( stream ); - prop.mType = Read_unsigned_int( stream ); - prop.mData = []; - stream.ReadBytes( prop.mData, 1, prop.mDataLength ); - -} -// ----------------------------------------------------------------------------------- -function ReadBinaryMaterial( stream, mat ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AIMATERIAL ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - mat.mNumAllocated = mat.mNumProperties = Read_unsigned_int( stream ); - if ( mat.mNumProperties ) { - - if ( mat.mProperties ) { - - delete mat.mProperties; - } - mat.mProperties = []; - for ( var i = 0; i < mat.mNumProperties; ++i ) { - - mat.mProperties[ i ] = new aiMaterialProperty(); - ReadBinaryMaterialProperty( stream, mat.mProperties[ i ] ); - } - } - -} -// ----------------------------------------------------------------------------------- -function ReadBinaryNodeAnim( stream, nd ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AINODEANIM ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - nd.mNodeName = Read_aiString( stream ); - nd.mNumPositionKeys = Read_unsigned_int( stream ); - nd.mNumRotationKeys = Read_unsigned_int( stream ); - nd.mNumScalingKeys = Read_unsigned_int( stream ); - nd.mPreState = Read_unsigned_int( stream ); - nd.mPostState = Read_unsigned_int( stream ); - if ( nd.mNumPositionKeys ) { - - if ( shortened ) { - - ReadBounds( stream, nd.mPositionKeys, nd.mNumPositionKeys ); - } // else write as usual - else { - - nd.mPositionKeys = []; - ReadArray_aiVectorKey( stream, nd.mPositionKeys, nd.mNumPositionKeys ); - } - } - if ( nd.mNumRotationKeys ) { - - if ( shortened ) { - - ReadBounds( stream, nd.mRotationKeys, nd.mNumRotationKeys ); - } // else write as usual - else { - - nd.mRotationKeys = []; - ReadArray_aiQuatKey( stream, nd.mRotationKeys, nd.mNumRotationKeys ); - } - } - if ( nd.mNumScalingKeys ) { - - if ( shortened ) { - - ReadBounds( stream, nd.mScalingKeys, nd.mNumScalingKeys ); - } // else write as usual - else { - - nd.mScalingKeys = []; - ReadArray_aiVectorKey( stream, nd.mScalingKeys, nd.mNumScalingKeys ); - } - } - -} -// ----------------------------------------------------------------------------------- -function ReadBinaryAnim( stream, anim ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AIANIMATION ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - anim.mName = Read_aiString( stream ); - anim.mDuration = Read_double( stream ); - anim.mTicksPerSecond = Read_double( stream ); - anim.mNumChannels = Read_unsigned_int( stream ); - if ( anim.mNumChannels ) { - - anim.mChannels = []; - for ( var a = 0; a < anim.mNumChannels; ++a ) { - - anim.mChannels[ a ] = new aiNodeAnim(); - ReadBinaryNodeAnim( stream, anim.mChannels[ a ] ); - } - } - -} - -function ReadBinaryTexture( stream, tex ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AITEXTURE ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - tex.mWidth = Read_unsigned_int( stream ); - tex.mHeight = Read_unsigned_int( stream ); - stream.ReadBytes( tex.achFormatHint, 1, 4 ); - if ( !shortened ) { - - if ( !tex.mHeight ) { - - tex.pcData = []; - stream.ReadBytes( tex.pcData, 1, tex.mWidth ); - } else { - - tex.pcData = [] - stream.ReadBytes( tex.pcData, 1, tex.mWidth * tex.mHeight * 4 ); - } - } - -} -// ----------------------------------------------------------------------------------- -function ReadBinaryLight( stream, l ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AILIGHT ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - l.mName = Read_aiString( stream ); - l.mType = Read_unsigned_int( stream ); - if ( l.mType != aiLightSource_DIRECTIONAL ) { - - l.mAttenuationConstant = readFloat( stream ); - l.mAttenuationLinear = readFloat( stream ); - l.mAttenuationQuadratic = readFloat( stream ); - } - l.mColorDiffuse = Read_aiColor3D( stream ); - l.mColorSpecular = Read_aiColor3D( stream ); - l.mColorAmbient = Read_aiColor3D( stream ); - if ( l.mType == aiLightSource_SPOT ) { - - l.mAngleInnerCone = readFloat( stream ); - l.mAngleOuterCone = readFloat( stream ); - } - -} -// ----------------------------------------------------------------------------------- -function ReadBinaryCamera( stream, cam ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AICAMERA ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - cam.mName = Read_aiString( stream ); - cam.mPosition = Read_aiVector3D( stream ); - cam.mLookAt = Read_aiVector3D( stream ); - cam.mUp = Read_aiVector3D( stream ); - cam.mHorizontalFOV = readFloat( stream ); - cam.mClipPlaneNear = readFloat( stream ); - cam.mClipPlaneFar = readFloat( stream ); - cam.mAspect = readFloat( stream ); - -} - -function ReadBinaryScene( stream, scene ) { - - var chunkID = Read_uint32_t( stream ); - ai_assert( chunkID == ASSBIN_CHUNK_AISCENE ); - /*uint32_t size =*/ - Read_uint32_t( stream ); - scene.mFlags = Read_unsigned_int( stream ); - scene.mNumMeshes = Read_unsigned_int( stream ); - scene.mNumMaterials = Read_unsigned_int( stream ); - scene.mNumAnimations = Read_unsigned_int( stream ); - scene.mNumTextures = Read_unsigned_int( stream ); - scene.mNumLights = Read_unsigned_int( stream ); - scene.mNumCameras = Read_unsigned_int( stream ); - // Read node graph - scene.mRootNode = new aiNode(); - scene.mRootNode = ReadBinaryNode( stream, null, 0 ); - // Read all meshes - if ( scene.mNumMeshes ) { - - scene.mMeshes = []; - for ( var i = 0; i < scene.mNumMeshes; ++i ) { - - scene.mMeshes[ i ] = new aiMesh(); - ReadBinaryMesh( stream, scene.mMeshes[ i ] ); - } - } - // Read materials - if ( scene.mNumMaterials ) { - - scene.mMaterials = []; - for ( var i = 0; i < scene.mNumMaterials; ++i ) { - - scene.mMaterials[ i ] = new aiMaterial(); - ReadBinaryMaterial( stream, scene.mMaterials[ i ] ); - } - } - // Read all animations - if ( scene.mNumAnimations ) { - - scene.mAnimations = []; - for ( var i = 0; i < scene.mNumAnimations; ++i ) { - - scene.mAnimations[ i ] = new aiAnimation(); - ReadBinaryAnim( stream, scene.mAnimations[ i ] ); - } - } - // Read all textures - if ( scene.mNumTextures ) { - - scene.mTextures = []; - for ( var i = 0; i < scene.mNumTextures; ++i ) { - - scene.mTextures[ i ] = new aiTexture(); - ReadBinaryTexture( stream, scene.mTextures[ i ] ); - } - } - // Read lights - if ( scene.mNumLights ) { - - scene.mLights = []; - for ( var i = 0; i < scene.mNumLights; ++i ) { - - scene.mLights[ i ] = new aiLight(); - ReadBinaryLight( stream, scene.mLights[ i ] ); - } - } - // Read cameras - if ( scene.mNumCameras ) { - - scene.mCameras = []; - for ( var i = 0; i < scene.mNumCameras; ++i ) { - - scene.mCameras[ i ] = new aiCamera(); - ReadBinaryCamera( stream, scene.mCameras[ i ] ); - } - } - -} -var aiOrigin_CUR = 0; -var aiOrigin_BEG = 1; - -function extendStream( stream ) { - - stream.readOffset = 0; - stream.Seek = function( off, ori ) { - - if ( ori == aiOrigin_CUR ) { - - stream.readOffset += off; - } - if ( ori == aiOrigin_BEG ) { - - stream.readOffset = off; - } - } - stream.ReadBytes = function( buff, size, n ) { - - var bytes = size * n; - for ( var i = 0; i < bytes; i++ ) - buff[ i ] = Read_uint8_t( this ); - } - stream.subArray32 = function( start, end ) { - - var buff = this.buffer; - var newbuff = buff.slice( start, end ); - return new Float32Array( newbuff ); - } - stream.subArrayUint16 = function( start, end ) { - - var buff = this.buffer; - var newbuff = buff.slice( start, end ); - return new Uint16Array( newbuff ); - } - stream.subArrayUint8 = function( start, end ) { - - var buff = this.buffer; - var newbuff = buff.slice( start, end ); - return new Uint8Array( newbuff ); - } - stream.subArrayUint32 = function( start, end ) { - - var buff = this.buffer; - var newbuff = buff.slice( start, end ); - return new Uint32Array( newbuff ); - } - -} - -function AssimpLoader() { - - this.load = function( url, callback ) { - - var xhr = new XMLHttpRequest(); - xhr.open( 'GET', url, true ); - xhr.responseType = 'arraybuffer'; - xhr.onerror = function( e ) { - - callback( e ); - } - xhr.onload = function( e ) { - - try { - - var time = performance.now(); - // response is unsigned 8 bit integer - var node = InternReadFile( this.response, url ); - console.info( "Parse in " + ( performance.now() - time ) ); - callback(null, node); - - } catch ( e ) { - - callback(e); - - } - }; - xhr.send(); - } - -} - -function InternReadFile( pFiledata, url ) { - - var pScene = new aiScene(); - pScene.baseURL = url; - var stream = new DataView( pFiledata ); - extendStream( stream ); - stream.Seek( 44, aiOrigin_CUR ); // signature - /*unsigned int versionMajor =*/ - var versionMajor = Read_unsigned_int( stream ); - /*unsigned int versionMinor =*/ - var versionMinor = Read_unsigned_int( stream ); - /*unsigned int versionRevision =*/ - var versionRevision = Read_unsigned_int( stream ); - /*unsigned int compileFlags =*/ - var compileFlags = Read_unsigned_int( stream ); - shortened = Read_uint16_t( stream ) > 0; - compressed = Read_uint16_t( stream ) > 0; - if ( shortened ) - throw "Shortened binaries are not supported!"; - stream.Seek( 256, aiOrigin_CUR ); // original filename - stream.Seek( 128, aiOrigin_CUR ); // options - stream.Seek( 64, aiOrigin_CUR ); // padding - if ( compressed ) { - - var uncompressedSize = Read_uint32_t( stream ); - var compressedSize = stream.FileSize() - stream.Tell(); - var compressedData = []; - stream.Read( compressedData, 1, compressedSize ); - var uncompressedData = []; - uncompress( uncompressedData, uncompressedSize, compressedData, compressedSize ); - var buff = new ArrayBuffer( uncompressedData ); - ReadBinaryScene( buff, pScene ); - } else { - - ReadBinaryScene( stream, pScene ); - return pScene.toTHREE(); - } - -} - -THREE.AssimpLoader = AssimpLoader - -})() \ No newline at end of file
false
Other
mrdoob
three.js
7744b5a7019063d53161e4104016639b85da26cb.json
remove math spherical example
examples/files.js
@@ -158,7 +158,6 @@ var files = { "webgl_materials_variations_toon", "webgl_materials_video", "webgl_materials_wireframe", - "webgl_math_spherical_distribution", "webgl_mirror", "webgl_mirror_nodes", "webgl_modifier_simplifier",
true
Other
mrdoob
three.js
7744b5a7019063d53161e4104016639b85da26cb.json
remove math spherical example
examples/webgl_math_spherical_distribution.html
@@ -1,238 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> - <head> - <title>three.js webgl - geometries</title> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> - <style> - body { - font-family: Monospace; - background-color: #000; - margin: 0px; - overflow: hidden; - } - </style> - </head> - <body> - - <script src="../build/three.js"></script> - - <script src="js/Detector.js"></script> - <script src="js/libs/stats.min.js"></script> - - <script> - - if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); - - var container, stats; - - var camera, scene, renderer; - - init(); - animate(); - - function init() { - - container = document.createElement( 'div' ); - document.body.appendChild( container ); - - camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 ); - camera.position.y = 300; - camera.position.z = 300; - - scene = new THREE.Scene(); - camera.lookAt( scene.position ); - - var light, object; - - scene.add( new THREE.AmbientLight( 0x808080 ) ); - - light = new THREE.DirectionalLight( 0xffffff ); - light.position.set( 0, 1, 0 ); - scene.add( light ); - - // var material = new THREE.MeshLambertMaterial( { - var material = new THREE.MeshPhongMaterial( { - vertexColors: THREE.VertexColors, - side: THREE.DoubleSide - } ); - - // create sphere colored with sphericalDist values - - var numSphereSegments = 100; - - var dist; - var geom; - var baseDist = new THREE.CosineSphericalDistribution(); - - dist = new THREE.LinearlyTransformedSphericalDistribution(baseDist) - .shear(-0.5, 0.0, 0.0); - geom = new THREE.SphereGeometry( 20, numSphereSegments, numSphereSegments ); - colorSphereWithDistributionValues(geom, dist); - object = new THREE.Mesh( geom, material ); - object.position.set( -100, 0, 0 ); - object.rotation.set( -Math.PI / 2.0, 0.0, 0.0 ); - scene.add( object ); - - dist = new THREE.LinearlyTransformedSphericalDistribution(baseDist) - .scale(0.5, 1.0, 1.0); - geom = new THREE.SphereGeometry( 20, numSphereSegments, numSphereSegments ); - colorSphereWithDistributionValues(geom, dist); - object = new THREE.Mesh( geom, material ); - object.position.set( -50, 0, 0 ); - object.rotation.set( -Math.PI / 2.0, 0.0, 0.0 ); - scene.add( object ); - - dist = new THREE.CosineSphericalDistribution(); - geom = new THREE.SphereGeometry( 20, numSphereSegments, numSphereSegments ); - colorSphereWithDistributionValues(geom, dist); - object = new THREE.Mesh( geom, material ); - object.position.set( 0, 0, 0 ); - object.rotation.set( -Math.PI / 2.0, 0.0, 0.0 ); - scene.add( object ); - - dist = new THREE.LinearlyTransformedSphericalDistribution(baseDist) - .scale(1.0, 0.5, 1.0); - geom = new THREE.SphereGeometry( 20, numSphereSegments, numSphereSegments ); - colorSphereWithDistributionValues(geom, dist); - object = new THREE.Mesh( geom, material ); - object.position.set( 50, 0, 0 ); - object.rotation.set( -Math.PI / 2.0, 0.0, 0.0 ); - scene.add( object ); - - dist = new THREE.LinearlyTransformedSphericalDistribution(baseDist) - .shear(0.0, -0.5, 0.0); - geom = new THREE.SphereGeometry( 20, numSphereSegments, numSphereSegments ); - colorSphereWithDistributionValues(geom, dist); - object = new THREE.Mesh( geom, material ); - object.position.set( 100, 0, 0 ); - object.rotation.set( -Math.PI / 2.0, 0.0, 0.0 ); - scene.add( object ); - - // - - renderer = new THREE.WebGLRenderer( { antialias: true } ); - renderer.setPixelRatio( window.devicePixelRatio ); - renderer.setSize( window.innerWidth, window.innerHeight ); - - container.appendChild( renderer.domElement ); - - stats = new Stats(); - container.appendChild( stats.dom ); - - // - - window.addEventListener( 'resize', onWindowResize, false ); - - } - - function colorSphereWithDistributionValues(geom, dist) { - - var maxVal = 0.65; - var sum = 0.0; - - var values = []; - - // calc dist values, and note max value to map colors - for ( var i = 0; i < geom.faces.length; i ++ ) { - - values.push({}); - var face = geom.faces[ i ]; - - for ( var j = 0; j < 3; j ++ ) { - var faceIdx = [ 'a', 'b', 'c' ][ j ]; - var pos = geom.vertices[ face[ faceIdx ] ]; - - var distValue = dist.valueAtPosVec3( pos ); - - // sum += distValue; - // maxVal = Math.max(maxVal, distValue); - - values[i][faceIdx] = distValue; - } - - } - - console.log('max: ' + maxVal); - console.log('sum: ' + sum); - - // set colors using maxValue to interpolate properly - for ( var i = 0; i < geom.faces.length; i ++ ) { - - var face = geom.faces[ i ]; - - for ( var j = 0; j < 3; j ++ ) { - - var red = new THREE.Color( 'red' ); - var blue = new THREE.Color( 'blue' ); - var white = new THREE.Color( 'white' ); - - var faceIdx = [ 'a', 'b', 'c' ][ j ]; - var distValue = values[i][faceIdx] / maxVal; - - var color; - if (distValue > 0.5) { - - // 1.0 -> 0.5: red -> white - color = red.lerp( white, 1.0 - ( ( distValue - 0.5 ) * 2.0 ) ); - - } else { - - // 0.5 -> 0.0: white -> blue - color = blue.lerp( white, distValue * 2.0 ); - - } - face.vertexColors[ j ] = color; - } - } - - geom.colorsNeedUpdate = true; - - } - - function onWindowResize() { - - camera.aspect = window.innerWidth / window.innerHeight; - camera.updateProjectionMatrix(); - - renderer.setSize( window.innerWidth, window.innerHeight ); - - } - - // - - function animate() { - - requestAnimationFrame( animate ); - - render(); - stats.update(); - - } - - function render() { - - var timer = Date.now() * 0.0001; - - // camera.position.x = Math.cos( timer ) * 800; - // camera.position.z = Math.sin( timer ) * 800; - - // camera.lookAt( scene.position ); - - // for ( var i = 0, l = scene.children.length; i < l; i ++ ) { - - // var object = scene.children[ i ]; - - // object.rotation.x = timer * 5; - // object.rotation.y = timer * 2.5; - - // } - - renderer.render( scene, camera ); - - } - - </script> - - </body> -</html>
true
Other
mrdoob
three.js
6439d83fff9e1d41c81a538665ee2dfa28df3709.json
Fix example reference in SpotLight docs Fix reference to the webgl_shadowmap_performance example
docs/api/lights/SpotLight.html
@@ -55,7 +55,7 @@ <h2>Extra Examples</h2> [example:webgl_materials_bumpmap materials / bumpmap]<br/> [example:webgl_shading_physical shading / physical]<br/> [example:webgl_shadowmap shadowmap]<br/> - [example:webgl_shadowmap_viewer shadowmap / performance]<br/> + [example:webgl_shadowmap_performance shadowmap / performance]<br/> [example:webgl_shadowmap_viewer shadowmap / viewer] </div>
false
Other
mrdoob
three.js
e65efda9df9aac730c5883f788bbc771e4d176a0.json
Fix old reference to gltf.clips
examples/webgl_loader_gltf.html
@@ -541,11 +541,11 @@ function toggleAnimations() { - var i, len = gltf.clips.length; + var i, len = gltf.animations.length; for (i = 0; i < len; i++) { - var clip = gltf.clips[i]; + var clip = gltf.animations[i]; var action = mixer.existingAction( clip ); if (action.isRunning()) {
false
Other
mrdoob
three.js
81e173ab2354b987e1a4c0138dd2c2b7c765fa18.json
add makeEmpty again
src/math/Box3.js
@@ -96,6 +96,8 @@ Box3.prototype = { setFromPoints: function ( points ) { + this.makeEmpty(); + for ( var i = 0, il = points.length; i < il; i ++ ) { this.expandByPoint( points[ i ] );
false
Other
mrdoob
three.js
306a8f1d9c4522292b8ffff5e285c150e84253db.json
return this (line)
src/math/Box3.js
@@ -58,6 +58,7 @@ Box3.prototype = { this.max.set( maxX, maxY, maxZ ); return this; + }, setFromBufferAttribute: function ( attribute ) {
false
Other
mrdoob
three.js
549f3ab6d0665efdade2f100c7e44ebeedbcf7fe.json
Fix typo with stars geometry There was no instance of 'geometry', yet vertices were being added to it, and a mesh was being created from it.
docs/api/materials/PointsMaterial.html
@@ -44,13 +44,13 @@ <h2>Examples</h2> star.y = THREE.Math.randFloatSpread( 2000 ); star.z = THREE.Math.randFloatSpread( 2000 ); - geometry.vertices.push( star ); + starsGeometry.vertices.push( star ) } var starsMaterial = new THREE.PointsMaterial( { color: 0x888888 } ) -var starField = new THREE.Points( geometry, starsMaterial ); +var starField = new THREE.Points( starsGeometry, starsMaterial ); scene.add( starField ); </code>
false
Other
mrdoob
three.js
088a75b92c6d4d27c2348e32e0ed300c5c938339.json
remove bower.json from package.json
package.json
@@ -15,8 +15,7 @@ "build/three.module.js", "src", "examples/js", - "examples/fonts", - "bower.json" + "examples/fonts" ], "directories": { "doc": "docs",
false
Other
mrdoob
three.js
d707242f4143eb5dcbada19858ffb1c8ab46d4e5.json
Fix object flickering with CanvasRenderer `Projector` loops over all visible objects using `o` as the loop variable, but another loop inside that one also uses `o`. Since `var`s are function-scoped, not block-scoped, this can prematurely advance the outer loop and skip rendering some objects entirely.
examples/js/renderers/Projector.js
@@ -444,9 +444,9 @@ THREE.Projector = function () { if ( groups.length > 0 ) { - for ( var o = 0; o < groups.length; o ++ ) { + for ( var g = 0; g < groups.length; g ++ ) { - var group = groups[ o ]; + var group = groups[ g ]; for ( var i = group.start, l = group.start + group.count; i < l; i += 3 ) {
false
Other
mrdoob
three.js
62e9cf5d740e1c87e39b6a4c05802a1ad65e0e9a.json
Remove extra semicolon in webvr_shadow
examples/webvr_shadow.html
@@ -47,7 +47,7 @@ camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.1, 10 ); dummy.add( camera ); - var geometry = new THREE.TorusKnotGeometry( 0.4, 0.15, 150, 20 );; + var geometry = new THREE.TorusKnotGeometry( 0.4, 0.15, 150, 20 ); var material = new THREE.MeshStandardMaterial( { roughness: 0.01, metalness: 0.2 } ); var mesh = new THREE.Mesh( geometry, material ); mesh.position.y = 0.75;
false
Other
mrdoob
three.js
7180e8f9b299967d27b9e2ad2737c36ee2c871e1.json
Remove unnecessary comma in webgl_rollercoaster
examples/webvr_rollercoaster.html
@@ -241,7 +241,7 @@ effect.render( scene, camera ); - }; + } effect.requestAnimationFrame( animate );
false
Other
mrdoob
three.js
a40964740d4e68cc6c9da9090ef2368b971b9ebf.json
Remove extra semicolon in webl_tonemapping
examples/webgl_tonemapping.html
@@ -132,7 +132,7 @@ group = new THREE.Group(); scene.add( group ); - var geometry = new THREE.TorusKnotGeometry( 18, 8, 150, 20 );; + var geometry = new THREE.TorusKnotGeometry( 18, 8, 150, 20 ); var mesh = new THREE.Mesh( geometry, standardMaterial ); mesh.castShadow = true; mesh.receiveShadow = true;
false
Other
mrdoob
three.js
aad415671ab6bbe50d2bf7a2eb188a16dd6f975f.json
Fix extra text in css tag in webgl_shaders_sky
examples/webgl_shaders_sky.html
@@ -16,7 +16,6 @@ background-color: #fff; margin: 0px; overflow: hidden; - text } #info {
false
Other
mrdoob
three.js
616d54fc9b5b0fb8b10097ed9ae6ec3eee7ce68c.json
Remove unnecessary comma in webgl_shaders_ocean
examples/webgl_shaders_ocean.html
@@ -108,7 +108,7 @@ sunDirection: light.position.clone().normalize(), sunColor: 0xffffff, waterColor: 0x001e0f, - distortionScale: 50.0, + distortionScale: 50.0 } );
false
Other
mrdoob
three.js
71db6586cd8843abbbdc9d9d6af5653f87eb7f8a.json
Add missing semicolon in webgl_physics_cloth
examples/webgl_physics_cloth.html
@@ -239,8 +239,8 @@ //var clothGeometry = new THREE.BufferGeometry(); var clothGeometry = new THREE.PlaneBufferGeometry( clothWidth, clothHeight, clothNumSegmentsZ, clothNumSegmentsY ); - clothGeometry.rotateY( Math.PI * 0.5 ) - clothGeometry.translate( clothPos.x, clothPos.y + clothHeight * 0.5, clothPos.z - clothWidth * 0.5 ) + clothGeometry.rotateY( Math.PI * 0.5 ); + clothGeometry.translate( clothPos.x, clothPos.y + clothHeight * 0.5, clothPos.z - clothWidth * 0.5 ); //var clothMaterial = new THREE.MeshLambertMaterial( { color: 0x0030A0, side: THREE.DoubleSide } ); var clothMaterial = new THREE.MeshLambertMaterial( { color: 0xFFFFFF, side: THREE.DoubleSide } ); cloth = new THREE.Mesh( clothGeometry, clothMaterial ); @@ -266,7 +266,7 @@ sbConfig.set_viterations( 10 ); sbConfig.set_piterations( 10 ); - clothSoftBody.setTotalMass( 0.9, false ) + clothSoftBody.setTotalMass( 0.9, false ); Ammo.castObject( clothSoftBody, Ammo.btCollisionObject ).getCollisionShape().setMargin( margin * 3 ); physicsWorld.addSoftBody( clothSoftBody, 1, -1 ); cloth.userData.physicsBody = clothSoftBody;
false
Other
mrdoob
three.js
65cefeda8c482e9a3d47b7b2ee52978e1c5b58c7.json
Remove unnecessary comma in webgl_nearestnaighbour
examples/webgl_nearestneighbour.html
@@ -128,7 +128,7 @@ pointShaderMaterial = new THREE.ShaderMaterial( { uniforms: { tex1: { value: imagePreviewTexture }, - zoom: { value: 9.0 }, + zoom: { value: 9.0 } }, vertexShader: document.getElementById( 'vertexshader' ).textContent, fragmentShader: document.getElementById( 'fragmentshader' ).textContent,
false