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 | ac325c657d352a294547d27d61244ff5db34df97.json | Add modulrized STLLoader. | examples/files.js | @@ -125,6 +125,7 @@ var files = {
"webgl_loader_sea3d_skinning",
"webgl_loader_sea3d_sound",
"webgl_loader_stl",
+ "webgl_loader_stl_module",
"webgl_loader_svg",
"webgl_loader_texture_dds",
"webgl_loader_texture_exr", | true |
Other | mrdoob | three.js | ac325c657d352a294547d27d61244ff5db34df97.json | Add modulrized STLLoader. | examples/jsm/loaders/STLLoader.js | @@ -0,0 +1,354 @@
+/**
+ * @author aleeper / http://adamleeper.com/
+ * @author mrdoob / http://mrdoob.com/
+ * @author gero3 / https://github.com/gero3
+ * @author Mugen87 / https://github.com/Mugen87
+ *
+ * Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs.
+ *
+ * Supports both binary and ASCII encoded files, with automatic detection of type.
+ *
+ * The loader returns a non-indexed buffer geometry.
+ *
+ * Limitations:
+ * Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL).
+ * There is perhaps some question as to how valid it is to always assume little-endian-ness.
+ * ASCII decoding assumes file is UTF-8.
+ *
+ * Usage:
+ * var loader = new STLLoader();
+ * loader.load( './models/stl/slotted_disk.stl', function ( geometry ) {
+ * scene.add( new Mesh( geometry ) );
+ * });
+ *
+ * For binary STLs geometry might contain colors for vertices. To use it:
+ * // use the same code to load STL as above
+ * if (geometry.hasColors) {
+ * material = new MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: VertexColors });
+ * } else { .... }
+ * var mesh = new Mesh( geometry, material );
+ */
+
+import {
+ BufferAttribute,
+ BufferGeometry,
+ DefaultLoadingManager,
+ FileLoader,
+ Float32BufferAttribute,
+ LoaderUtils,
+ Vector3
+} from "../../../build/three.module.js";
+
+
+var STLLoader = function ( manager ) {
+
+ this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
+
+};
+
+STLLoader.prototype = {
+
+ constructor: STLLoader,
+
+ load: function ( url, onLoad, onProgress, onError ) {
+
+ var scope = this;
+
+ var loader = new FileLoader( scope.manager );
+ loader.setPath( scope.path );
+ loader.setResponseType( 'arraybuffer' );
+ loader.load( url, function ( text ) {
+
+ try {
+
+ onLoad( scope.parse( text ) );
+
+ } catch ( exception ) {
+
+ if ( onError ) {
+
+ onError( exception );
+
+ }
+
+ }
+
+ }, onProgress, onError );
+
+ },
+
+ setPath: function ( value ) {
+
+ this.path = value;
+ return this;
+
+ },
+
+ parse: function ( data ) {
+
+ function isBinary( data ) {
+
+ var expect, face_size, n_faces, reader;
+ reader = new DataView( data );
+ face_size = ( 32 / 8 * 3 ) + ( ( 32 / 8 * 3 ) * 3 ) + ( 16 / 8 );
+ n_faces = reader.getUint32( 80, true );
+ expect = 80 + ( 32 / 8 ) + ( n_faces * face_size );
+
+ if ( expect === reader.byteLength ) {
+
+ return true;
+
+ }
+
+ // 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. So, check the first 5 bytes for 'solid'.
+
+ // Several encodings, such as UTF-8, precede the text with up to 5 bytes:
+ // https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding
+ // Search for "solid" to start anywhere after those prefixes.
+
+ // US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd'
+
+ var solid = [ 115, 111, 108, 105, 100 ];
+
+ for ( var off = 0; off < 5; off ++ ) {
+
+ // If "solid" text is matched to the current offset, declare it to be an ASCII STL.
+
+ if ( matchDataViewAt ( solid, reader, off ) ) return false;
+
+ }
+
+ // Couldn't find "solid" text at the beginning; it is binary STL.
+
+ return true;
+
+ }
+
+ function matchDataViewAt( query, reader, offset ) {
+
+ // Check if each byte in query matches the corresponding byte from the current offset
+
+ for ( var i = 0, il = query.length; i < il; i ++ ) {
+
+ if ( query[ i ] !== reader.getUint8( offset + i, false ) ) return false;
+
+ }
+
+ return true;
+
+ }
+
+ function parseBinary( data ) {
+
+ var reader = new DataView( data );
+ var faces = reader.getUint32( 80, true );
+
+ var r, g, b, hasColors = false, colors;
+ var defaultR, defaultG, defaultB, alpha;
+
+ // process STL header
+ // check for default color in header ("COLOR=rgba" sequence).
+
+ for ( var index = 0; index < 80 - 10; index ++ ) {
+
+ if ( ( reader.getUint32( index, false ) == 0x434F4C4F /*COLO*/ ) &&
+ ( reader.getUint8( index + 4 ) == 0x52 /*'R'*/ ) &&
+ ( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) {
+
+ hasColors = true;
+ colors = [];
+
+ defaultR = reader.getUint8( index + 6 ) / 255;
+ defaultG = reader.getUint8( index + 7 ) / 255;
+ defaultB = reader.getUint8( index + 8 ) / 255;
+ alpha = reader.getUint8( index + 9 ) / 255;
+
+ }
+
+ }
+
+ var dataOffset = 84;
+ var faceLength = 12 * 4 + 2;
+
+ var geometry = new BufferGeometry();
+
+ var vertices = [];
+ var normals = [];
+
+ for ( var face = 0; face < faces; face ++ ) {
+
+ var start = dataOffset + face * faceLength;
+ var normalX = reader.getFloat32( start, true );
+ var normalY = reader.getFloat32( start + 4, true );
+ var normalZ = reader.getFloat32( start + 8, true );
+
+ if ( hasColors ) {
+
+ var packedColor = reader.getUint16( start + 48, true );
+
+ if ( ( packedColor & 0x8000 ) === 0 ) {
+
+ // facet has its own unique color
+
+ r = ( packedColor & 0x1F ) / 31;
+ g = ( ( packedColor >> 5 ) & 0x1F ) / 31;
+ b = ( ( packedColor >> 10 ) & 0x1F ) / 31;
+
+ } else {
+
+ r = defaultR;
+ g = defaultG;
+ b = defaultB;
+
+ }
+
+ }
+
+ for ( var i = 1; i <= 3; i ++ ) {
+
+ var vertexstart = start + i * 12;
+
+ vertices.push( reader.getFloat32( vertexstart, true ) );
+ vertices.push( reader.getFloat32( vertexstart + 4, true ) );
+ vertices.push( reader.getFloat32( vertexstart + 8, true ) );
+
+ normals.push( normalX, normalY, normalZ );
+
+ if ( hasColors ) {
+
+ colors.push( r, g, b );
+
+ }
+
+ }
+
+ }
+
+ geometry.addAttribute( 'position', new BufferAttribute( new Float32Array( vertices ), 3 ) );
+ geometry.addAttribute( 'normal', new BufferAttribute( new Float32Array( normals ), 3 ) );
+
+ if ( hasColors ) {
+
+ geometry.addAttribute( 'color', new BufferAttribute( new Float32Array( colors ), 3 ) );
+ geometry.hasColors = true;
+ geometry.alpha = alpha;
+
+ }
+
+ return geometry;
+
+ }
+
+ function parseASCII( data ) {
+
+ var geometry = new BufferGeometry();
+ var patternFace = /facet([\s\S]*?)endfacet/g;
+ var faceCounter = 0;
+
+ var patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
+ var patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' );
+ var patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' );
+
+ var vertices = [];
+ var normals = [];
+
+ var normal = new Vector3();
+
+ var result;
+
+ while ( ( result = patternFace.exec( data ) ) !== null ) {
+
+ var vertexCountPerFace = 0;
+ var normalCountPerFace = 0;
+
+ var text = result[ 0 ];
+
+ while ( ( result = patternNormal.exec( text ) ) !== null ) {
+
+ normal.x = parseFloat( result[ 1 ] );
+ normal.y = parseFloat( result[ 2 ] );
+ normal.z = parseFloat( result[ 3 ] );
+ normalCountPerFace ++;
+
+ }
+
+ while ( ( result = patternVertex.exec( text ) ) !== null ) {
+
+ vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) );
+ normals.push( normal.x, normal.y, normal.z );
+ vertexCountPerFace ++;
+
+ }
+
+ // every face have to own ONE valid normal
+
+ if ( normalCountPerFace !== 1 ) {
+
+ console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter );
+
+ }
+
+ // each face have to own THREE valid vertices
+
+ if ( vertexCountPerFace !== 3 ) {
+
+ console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter );
+
+ }
+
+ faceCounter ++;
+
+ }
+
+ geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+ geometry.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+
+ return geometry;
+
+ }
+
+ function ensureString( buffer ) {
+
+ if ( typeof buffer !== 'string' ) {
+
+ return LoaderUtils.decodeText( new Uint8Array( buffer ) );
+
+ }
+
+ return buffer;
+
+ }
+
+ function ensureBinary( buffer ) {
+
+ if ( typeof buffer === 'string' ) {
+
+ var array_buffer = new Uint8Array( buffer.length );
+ for ( var i = 0; i < buffer.length; i ++ ) {
+
+ array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian
+
+ }
+ return array_buffer.buffer || array_buffer;
+
+ } else {
+
+ return buffer;
+
+ }
+
+ }
+
+ // start
+
+ var binData = ensureBinary( data );
+
+ return isBinary( binData ) ? parseBinary( binData ) : parseASCII( ensureString( data ) );
+
+ }
+
+};
+
+export { STLLoader }; | true |
Other | mrdoob | three.js | ac325c657d352a294547d27d61244ff5db34df97.json | Add modulrized STLLoader. | examples/webgl_loader_stl_module.html | @@ -0,0 +1,272 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>three.js webgl - STL</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: #000000;
+ margin: 0px;
+ overflow: hidden;
+ }
+
+ #info {
+ color: #fff;
+ position: absolute;
+ top: 10px;
+ width: 100%;
+ text-align: center;
+ z-index: 100;
+ display:block;
+
+ }
+
+ a { color: skyblue }
+ .button { background:#999; color:#eee; padding:0.2em 0.5em; cursor:pointer }
+ .highlight { background:orange; color:#fff; }
+
+ span {
+ display: inline-block;
+ width: 60px;
+ text-align: center;
+ }
+
+ </style>
+ </head>
+ <body>
+ <div id="info">
+ <a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> -
+ STL loader test by <a href="https://github.com/aleeper" target="_blank" rel="noopener">aleeper</a>. PR2 head from <a href="http://www.ros.org/wiki/pr2_description">www.ros.org</a>
+ </div>
+
+ <script src="js/WebGL.js"></script>
+ <script src="js/libs/stats.min.js"></script>
+
+ <script type='module'>
+ import {
+ PerspectiveCamera,
+ Scene,
+ WebGLRenderer,
+ Mesh,
+ HemisphereLight,
+ DirectionalLight,
+ Vector3,
+ Color,
+ VertexColors,
+ Fog,
+ PlaneBufferGeometry,
+ MeshPhongMaterial
+ } from '../build/three.module.js';
+
+ import { STLLoader } from './jsm/loaders/STLLoader.js';
+
+
+ if ( WEBGL.isWebGLAvailable() === false ) {
+
+ document.body.appendChild( WEBGL.getWebGLErrorMessage() );
+
+ }
+
+ var container, stats;
+
+ var camera, cameraTarget, scene, renderer;
+
+ init();
+ animate();
+
+ function init() {
+
+ container = document.createElement( 'div' );
+ document.body.appendChild( container );
+
+ camera = new PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 1, 15 );
+ camera.position.set( 3, 0.15, 3 );
+
+ cameraTarget = new Vector3( 0, - 0.25, 0 );
+
+ scene = new Scene();
+ scene.background = new Color( 0x72645b );
+ scene.fog = new Fog( 0x72645b, 2, 15 );
+
+
+ // Ground
+
+ var plane = new Mesh(
+ new PlaneBufferGeometry( 40, 40 ),
+ new MeshPhongMaterial( { color: 0x999999, specular: 0x101010 } )
+ );
+ plane.rotation.x = - Math.PI / 2;
+ plane.position.y = - 0.5;
+ scene.add( plane );
+
+ plane.receiveShadow = true;
+
+
+ // ASCII file
+
+ var loader = new STLLoader();
+ loader.load( './models/stl/ascii/slotted_disk.stl', function ( geometry ) {
+
+ var material = new MeshPhongMaterial( { color: 0xff5533, specular: 0x111111, shininess: 200 } );
+ var mesh = new Mesh( geometry, material );
+
+ mesh.position.set( 0, - 0.25, 0.6 );
+ mesh.rotation.set( 0, - Math.PI / 2, 0 );
+ mesh.scale.set( 0.5, 0.5, 0.5 );
+
+ mesh.castShadow = true;
+ mesh.receiveShadow = true;
+
+ scene.add( mesh );
+
+ } );
+
+
+ // Binary files
+
+ var material = new MeshPhongMaterial( { color: 0xAAAAAA, specular: 0x111111, shininess: 200 } );
+
+ loader.load( './models/stl/binary/pr2_head_pan.stl', function ( geometry ) {
+
+ var mesh = new Mesh( geometry, material );
+
+ mesh.position.set( 0, - 0.37, - 0.6 );
+ mesh.rotation.set( - Math.PI / 2, 0, 0 );
+ mesh.scale.set( 2, 2, 2 );
+
+ mesh.castShadow = true;
+ mesh.receiveShadow = true;
+
+ scene.add( mesh );
+
+ } );
+
+ loader.load( './models/stl/binary/pr2_head_tilt.stl', function ( geometry ) {
+
+ var mesh = new Mesh( geometry, material );
+
+ mesh.position.set( 0.136, - 0.37, - 0.6 );
+ mesh.rotation.set( - Math.PI / 2, 0.3, 0 );
+ mesh.scale.set( 2, 2, 2 );
+
+ mesh.castShadow = true;
+ mesh.receiveShadow = true;
+
+ scene.add( mesh );
+
+ } );
+
+ // Colored binary STL
+ loader.load( './models/stl/binary/colored.stl', function ( geometry ) {
+
+ var meshMaterial = material;
+ if ( geometry.hasColors ) {
+
+ meshMaterial = new MeshPhongMaterial( { opacity: geometry.alpha, vertexColors: VertexColors } );
+
+ }
+
+ var mesh = new Mesh( geometry, meshMaterial );
+
+ mesh.position.set( 0.5, 0.2, 0 );
+ mesh.rotation.set( - Math.PI / 2, Math.PI / 2, 0 );
+ mesh.scale.set( 0.3, 0.3, 0.3 );
+
+ mesh.castShadow = true;
+ mesh.receiveShadow = true;
+
+ scene.add( mesh );
+
+ } );
+
+
+ // Lights
+
+ scene.add( new HemisphereLight( 0x443333, 0x111122 ) );
+
+ addShadowedLight( 1, 1, 1, 0xffffff, 1.35 );
+ addShadowedLight( 0.5, 1, - 1, 0xffaa00, 1 );
+ // renderer
+
+ renderer = new WebGLRenderer( { antialias: true } );
+ renderer.setPixelRatio( window.devicePixelRatio );
+ renderer.setSize( window.innerWidth, window.innerHeight );
+
+ renderer.gammaInput = true;
+ renderer.gammaOutput = true;
+
+ renderer.shadowMap.enabled = true;
+
+ container.appendChild( renderer.domElement );
+
+ // stats
+
+ stats = new Stats();
+ container.appendChild( stats.dom );
+
+ //
+
+ window.addEventListener( 'resize', onWindowResize, false );
+
+ }
+
+ function addShadowedLight( x, y, z, color, intensity ) {
+
+ var directionalLight = new DirectionalLight( color, intensity );
+ directionalLight.position.set( x, y, z );
+ scene.add( directionalLight );
+
+ directionalLight.castShadow = true;
+
+ var d = 1;
+ directionalLight.shadow.camera.left = - d;
+ directionalLight.shadow.camera.right = d;
+ directionalLight.shadow.camera.top = d;
+ directionalLight.shadow.camera.bottom = - d;
+
+ directionalLight.shadow.camera.near = 1;
+ directionalLight.shadow.camera.far = 4;
+
+ directionalLight.shadow.mapSize.width = 1024;
+ directionalLight.shadow.mapSize.height = 1024;
+
+ directionalLight.shadow.bias = - 0.002;
+
+ }
+
+ 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.0005;
+
+ camera.position.x = Math.cos( timer ) * 3;
+ camera.position.z = Math.sin( timer ) * 3;
+
+ camera.lookAt( cameraTarget );
+
+ renderer.render( scene, camera );
+
+ }
+
+ </script>
+ </body>
+</html> | true |
Other | mrdoob | three.js | ac325c657d352a294547d27d61244ff5db34df97.json | Add modulrized STLLoader. | utils/modularize.js | @@ -23,6 +23,7 @@ var files = [
{ path: 'loaders/GLTFLoader.js', ignoreList: [ 'NoSide', 'Matrix2', 'DDSLoader' ] },
{ path: 'loaders/OBJLoader.js', ignoreList: [] },
{ path: 'loaders/MTLLoader.js', ignoreList: [] },
+ { path: 'loaders/STLLoader.js', ignoreList: [] },
{ path: 'pmrem/PMREMCubeUVPacker.js', ignoreList: [] },
{ path: 'pmrem/PMREMGenerator.js', ignoreList: [] }, | true |
Other | mrdoob | three.js | 0693261e5cc45c98d7b2d57e4d884b29c3ec0725.json | fix lgtm error | examples/js/loaders/SVGLoader.js | @@ -56,37 +56,37 @@ THREE.SVGLoader.prototype = {
case 'path':
style = parseStyle( node, style );
- if ( node.hasAttribute( 'd' ) ) path = parsePathNode( node, style );
+ if ( node.hasAttribute( 'd' ) ) path = parsePathNode( node );
break;
case 'rect':
style = parseStyle( node, style );
- path = parseRectNode( node, style );
+ path = parseRectNode( node );
break;
case 'polygon':
style = parseStyle( node, style );
- path = parsePolygonNode( node, style );
+ path = parsePolygonNode( node );
break;
case 'polyline':
style = parseStyle( node, style );
- path = parsePolylineNode( node, style );
+ path = parsePolylineNode( node );
break;
case 'circle':
style = parseStyle( node, style );
- path = parseCircleNode( node, style );
+ path = parseCircleNode( node );
break;
case 'ellipse':
style = parseStyle( node, style );
- path = parseEllipseNode( node, style );
+ path = parseEllipseNode( node );
break;
case 'line':
style = parseStyle( node, style );
- path = parseLineNode( node, style );
+ path = parseLineNode( node );
break;
default: | false |
Other | mrdoob | three.js | 5cb6d53903436d5259568d5ddd5ac929c92f94a3.json | fix lgtm error | examples/js/loaders/AssimpLoader.js | @@ -834,20 +834,6 @@ THREE.AssimpLoader.prototype = {
}
- 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;
@@ -856,7 +842,7 @@ THREE.AssimpLoader.prototype = {
this.a = 0;
this.toTHREE = function () {
- return new THREE.Color( this.r, this.g, this.b, 1 );
+ return new THREE.Color( this.r, this.g, this.b );
};
@@ -1536,17 +1522,6 @@ THREE.AssimpLoader.prototype = {
}
- 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();
@@ -1642,12 +1617,6 @@ THREE.AssimpLoader.prototype = {
}
- 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 ); | true |
Other | mrdoob | three.js | 5cb6d53903436d5259568d5ddd5ac929c92f94a3.json | fix lgtm error | examples/jsm/loaders/AssimpLoader.js | @@ -856,20 +856,6 @@ AssimpLoader.prototype = {
}
- function aiColor4D() {
-
- this.r = 0;
- this.g = 0;
- this.b = 0;
- this.a = 0;
- this.toTHREE = function () {
-
- return new Color( this.r, this.g, this.b, this.a );
-
- };
-
- }
-
function aiColor3D() {
this.r = 0;
@@ -1558,17 +1544,6 @@ AssimpLoader.prototype = {
}
- 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();
@@ -1664,12 +1639,6 @@ AssimpLoader.prototype = {
}
- 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 ); | true |
Other | mrdoob | three.js | de46d2567ccec1678844252a89f7792bcec0a1ce.json | remove redundant param | src/renderers/webgl/WebGLProgram.js | @@ -613,8 +613,8 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters,
// console.log( '*VERTEX*', vertexGlsl );
// console.log( '*FRAGMENT*', fragmentGlsl );
- var glVertexShader = WebGLShader( gl, gl.VERTEX_SHADER, vertexGlsl, renderer.debug.checkShaderErrors );
- var glFragmentShader = WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentGlsl, renderer.debug.checkShaderErrors );
+ var glVertexShader = WebGLShader( gl, gl.VERTEX_SHADER, vertexGlsl );
+ var glFragmentShader = WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentGlsl );
gl.attachShader( program, glVertexShader );
gl.attachShader( program, glFragmentShader ); | true |
Other | mrdoob | three.js | de46d2567ccec1678844252a89f7792bcec0a1ce.json | remove redundant param | src/renderers/webgl/WebGLShader.d.ts | @@ -1,3 +1,3 @@
export class WebGLShader {
- constructor(gl: any, type: string, string: string, debug: boolean);
+ constructor(gl: any, type: string, string: string);
} | true |
Other | mrdoob | three.js | 518d2463af8cd73a6c21137728493ff98124f857.json | Remove remaining IIFEs from core. | src/Three.Legacy.js | @@ -594,17 +594,10 @@ Object.assign( Matrix4.prototype, {
},
getPosition: function () {
- var v1;
+ console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' );
+ return new Vector3().setFromMatrixColumn( this, 3 );
- return function getPosition() {
-
- if ( v1 === undefined ) v1 = new Vector3();
- console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' );
- return v1.setFromMatrixColumn( this, 3 );
-
- };
-
- }(),
+ },
setRotationFromQuaternion: function ( q ) {
console.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' ); | true |
Other | mrdoob | three.js | 518d2463af8cd73a6c21137728493ff98124f857.json | Remove remaining IIFEs from core. | src/animation/PropertyBinding.js | @@ -9,7 +9,10 @@
*/
// Characters [].:/ are reserved for track binding syntax.
-var RESERVED_CHARS_RE = '\\[\\]\\.:\\/';
+var _RESERVED_CHARS_RE = '\\[\\]\\.:\\/';
+
+var _reservedRe;
+var _trackRe, _supportedObjectNames;
function Composite( targetGroup, path, optionalParsedPath ) {
@@ -109,101 +112,101 @@ Object.assign( PropertyBinding, {
* @param {string} name Node name to be sanitized.
* @return {string}
*/
- sanitizeNodeName: ( function () {
+ sanitizeNodeName: function ( name ) {
- var reservedRe = new RegExp( '[' + RESERVED_CHARS_RE + ']', 'g' );
+ if ( _reservedRe === undefined ) {
- return function sanitizeNodeName( name ) {
+ _reservedRe = new RegExp( '[' + _RESERVED_CHARS_RE + ']', 'g' );
- return name.replace( /\s/g, '_' ).replace( reservedRe, '' );
+ }
- };
+ return name.replace( /\s/g, '_' ).replace( _reservedRe, '' );
- }() ),
+ },
- parseTrackName: function () {
+ parseTrackName: function ( trackName ) {
- // Attempts to allow node names from any language. ES5's `\w` regexp matches
- // only latin characters, and the unicode \p{L} is not yet supported. So
- // instead, we exclude reserved characters and match everything else.
- var wordChar = '[^' + RESERVED_CHARS_RE + ']';
- var wordCharOrDot = '[^' + RESERVED_CHARS_RE.replace( '\\.', '' ) + ']';
+ if ( _supportedObjectNames === undefined ) {
- // Parent directories, delimited by '/' or ':'. Currently unused, but must
- // be matched to parse the rest of the track name.
- var directoryRe = /((?:WC+[\/:])*)/.source.replace( 'WC', wordChar );
+ // Attempts to allow node names from any language. ES5's `\w` regexp matches
+ // only latin characters, and the unicode \p{L} is not yet supported. So
+ // instead, we exclude reserved characters and match everything else.
+ var wordChar = '[^' + _RESERVED_CHARS_RE + ']';
+ var wordCharOrDot = '[^' + _RESERVED_CHARS_RE.replace( '\\.', '' ) + ']';
- // Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'.
- var nodeRe = /(WCOD+)?/.source.replace( 'WCOD', wordCharOrDot );
+ // Parent directories, delimited by '/' or ':'. Currently unused, but must
+ // be matched to parse the rest of the track name.
+ var directoryRe = /((?:WC+[\/:])*)/.source.replace( 'WC', wordChar );
- // Object on target node, and accessor. May not contain reserved
- // characters. Accessor may contain any character except closing bracket.
- var objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace( 'WC', wordChar );
+ // Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'.
+ var nodeRe = /(WCOD+)?/.source.replace( 'WCOD', wordCharOrDot );
- // Property and accessor. May not contain reserved characters. Accessor may
- // contain any non-bracket characters.
- var propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace( 'WC', wordChar );
+ // Object on target node, and accessor. May not contain reserved
+ // characters. Accessor may contain any character except closing bracket.
+ var objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace( 'WC', wordChar );
- var trackRe = new RegExp( ''
- + '^'
- + directoryRe
- + nodeRe
- + objectRe
- + propertyRe
- + '$'
- );
+ // Property and accessor. May not contain reserved characters. Accessor may
+ // contain any non-bracket characters.
+ var propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace( 'WC', wordChar );
- var supportedObjectNames = [ 'material', 'materials', 'bones' ];
+ _trackRe = new RegExp( ''
+ + '^'
+ + directoryRe
+ + nodeRe
+ + objectRe
+ + propertyRe
+ + '$'
+ );
- return function parseTrackName( trackName ) {
+ _supportedObjectNames = [ 'material', 'materials', 'bones' ];
- var matches = trackRe.exec( trackName );
+ }
- if ( ! matches ) {
+ var matches = _trackRe.exec( trackName );
- throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName );
+ if ( ! matches ) {
- }
+ throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName );
- var results = {
- // directoryName: matches[ 1 ], // (tschw) currently unused
- nodeName: matches[ 2 ],
- objectName: matches[ 3 ],
- objectIndex: matches[ 4 ],
- propertyName: matches[ 5 ], // required
- propertyIndex: matches[ 6 ]
- };
+ }
- var lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' );
+ var results = {
+ // directoryName: matches[ 1 ], // (tschw) currently unused
+ nodeName: matches[ 2 ],
+ objectName: matches[ 3 ],
+ objectIndex: matches[ 4 ],
+ propertyName: matches[ 5 ], // required
+ propertyIndex: matches[ 6 ]
+ };
- if ( lastDot !== undefined && lastDot !== - 1 ) {
+ var lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' );
- var objectName = results.nodeName.substring( lastDot + 1 );
+ if ( lastDot !== undefined && lastDot !== - 1 ) {
- // Object names must be checked against a whitelist. Otherwise, there
- // is no way to parse 'foo.bar.baz': 'baz' must be a property, but
- // 'bar' could be the objectName, or part of a nodeName (which can
- // include '.' characters).
- if ( supportedObjectNames.indexOf( objectName ) !== - 1 ) {
+ var objectName = results.nodeName.substring( lastDot + 1 );
- results.nodeName = results.nodeName.substring( 0, lastDot );
- results.objectName = objectName;
+ // Object names must be checked against a whitelist. Otherwise, there
+ // is no way to parse 'foo.bar.baz': 'baz' must be a property, but
+ // 'bar' could be the objectName, or part of a nodeName (which can
+ // include '.' characters).
+ if ( _supportedObjectNames.indexOf( objectName ) !== - 1 ) {
- }
+ results.nodeName = results.nodeName.substring( 0, lastDot );
+ results.objectName = objectName;
}
- if ( results.propertyName === null || results.propertyName.length === 0 ) {
+ }
- throw new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName );
+ if ( results.propertyName === null || results.propertyName.length === 0 ) {
- }
+ throw new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName );
- return results;
+ }
- };
+ return results;
- }(),
+ },
findNode: function ( root, nodeName ) {
| true |
Other | mrdoob | three.js | 518d2463af8cd73a6c21137728493ff98124f857.json | Remove remaining IIFEs from core. | src/core/BufferGeometry.js | @@ -15,11 +15,14 @@ import { arrayMax } from '../utils.js';
* @author mrdoob / http://mrdoob.com/
*/
-var bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id
+var _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id
+var _m1, _obj, _offset;
+var _box, _boxMorphTargets;
+var _vector;
function BufferGeometry() {
- Object.defineProperty( this, 'id', { value: bufferGeometryId += 2 } );
+ Object.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } );
this.uuid = _Math.generateUUID();
@@ -182,129 +185,103 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
},
- rotateX: function () {
+ rotateX: function ( angle ) {
// rotate geometry around world x-axis
- var m1 = new Matrix4();
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- return function rotateX( angle ) {
+ _m1.makeRotationX( angle );
- m1.makeRotationX( angle );
+ this.applyMatrix( _m1 );
- this.applyMatrix( m1 );
-
- return this;
-
- };
+ return this;
- }(),
+ },
- rotateY: function () {
+ rotateY: function ( angle ) {
// rotate geometry around world y-axis
- var m1 = new Matrix4();
-
- return function rotateY( angle ) {
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- m1.makeRotationY( angle );
+ _m1.makeRotationY( angle );
- this.applyMatrix( m1 );
+ this.applyMatrix( _m1 );
- return this;
-
- };
+ return this;
- }(),
+ },
- rotateZ: function () {
+ rotateZ: function ( angle ) {
// rotate geometry around world z-axis
- var m1 = new Matrix4();
-
- return function rotateZ( angle ) {
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- m1.makeRotationZ( angle );
+ _m1.makeRotationZ( angle );
- this.applyMatrix( m1 );
-
- return this;
+ this.applyMatrix( _m1 );
- };
+ return this;
- }(),
+ },
- translate: function () {
+ translate: function ( x, y, z ) {
// translate geometry
- var m1 = new Matrix4();
-
- return function translate( x, y, z ) {
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- m1.makeTranslation( x, y, z );
+ _m1.makeTranslation( x, y, z );
- this.applyMatrix( m1 );
+ this.applyMatrix( _m1 );
- return this;
-
- };
+ return this;
- }(),
+ },
- scale: function () {
+ scale: function ( x, y, z ) {
// scale geometry
- var m1 = new Matrix4();
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- return function scale( x, y, z ) {
+ _m1.makeScale( x, y, z );
- m1.makeScale( x, y, z );
-
- this.applyMatrix( m1 );
-
- return this;
-
- };
+ this.applyMatrix( _m1 );
- }(),
+ return this;
- lookAt: function () {
+ },
- var obj = new Object3D();
+ lookAt: function ( vector ) {
- return function lookAt( vector ) {
+ if ( _obj === undefined ) _obj = new Object3D();
- obj.lookAt( vector );
+ _obj.lookAt( vector );
- obj.updateMatrix();
+ _obj.updateMatrix();
- this.applyMatrix( obj.matrix );
+ this.applyMatrix( _obj.matrix );
- };
+ return this;
- }(),
+ },
center: function () {
- var offset = new Vector3();
+ if ( _offset === undefined ) _offset = new Vector3();
- return function center() {
+ this.computeBoundingBox();
- this.computeBoundingBox();
-
- this.boundingBox.getCenter( offset ).negate();
+ this.boundingBox.getCenter( _offset ).negate();
- this.translate( offset.x, offset.y, offset.z );
-
- return this;
+ this.translate( _offset.x, _offset.y, _offset.z );
- };
+ return this;
- }(),
+ },
setFromObject: function ( object ) {
@@ -601,144 +578,144 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
computeBoundingBox: function () {
- var box = new Box3();
+ if ( _box === undefined ) {
- return function computeBoundingBox() {
+ _box = new Box3();
- if ( this.boundingBox === null ) {
+ }
- this.boundingBox = new Box3();
+ if ( this.boundingBox === null ) {
- }
+ this.boundingBox = new Box3();
- var position = this.attributes.position;
- var morphAttributesPosition = this.morphAttributes.position;
+ }
- if ( position !== undefined ) {
+ var position = this.attributes.position;
+ var morphAttributesPosition = this.morphAttributes.position;
- this.boundingBox.setFromBufferAttribute( position );
+ if ( position !== undefined ) {
- // process morph attributes if present
+ this.boundingBox.setFromBufferAttribute( position );
- if ( morphAttributesPosition ) {
+ // process morph attributes if present
- for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+ if ( morphAttributesPosition ) {
- var morphAttribute = morphAttributesPosition[ i ];
- box.setFromBufferAttribute( morphAttribute );
+ for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
- this.boundingBox.expandByPoint( box.min );
- this.boundingBox.expandByPoint( box.max );
+ var morphAttribute = morphAttributesPosition[ i ];
+ _box.setFromBufferAttribute( morphAttribute );
- }
+ this.boundingBox.expandByPoint( _box.min );
+ this.boundingBox.expandByPoint( _box.max );
}
- } else {
+ }
- this.boundingBox.makeEmpty();
+ } else {
- }
+ this.boundingBox.makeEmpty();
- if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {
+ }
- console.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this );
+ if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {
- }
+ console.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this );
- };
+ }
- }(),
+ },
computeBoundingSphere: function () {
- var box = new Box3();
- var boxMorphTargets = new Box3();
- var vector = new Vector3();
+ if ( _boxMorphTargets === undefined ) {
- return function computeBoundingSphere() {
+ _box = new Box3();
+ _vector = new Vector3();
+ _boxMorphTargets = new Box3();
- if ( this.boundingSphere === null ) {
+ }
- this.boundingSphere = new Sphere();
+ if ( this.boundingSphere === null ) {
- }
+ this.boundingSphere = new Sphere();
- var position = this.attributes.position;
- var morphAttributesPosition = this.morphAttributes.position;
+ }
- if ( position ) {
+ var position = this.attributes.position;
+ var morphAttributesPosition = this.morphAttributes.position;
- // first, find the center of the bounding sphere
+ if ( position ) {
- var center = this.boundingSphere.center;
+ // first, find the center of the bounding sphere
- box.setFromBufferAttribute( position );
+ var center = this.boundingSphere.center;
- // process morph attributes if present
+ _box.setFromBufferAttribute( position );
- if ( morphAttributesPosition ) {
+ // process morph attributes if present
- for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+ if ( morphAttributesPosition ) {
- var morphAttribute = morphAttributesPosition[ i ];
- boxMorphTargets.setFromBufferAttribute( morphAttribute );
+ for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
- box.expandByPoint( boxMorphTargets.min );
- box.expandByPoint( boxMorphTargets.max );
+ var morphAttribute = morphAttributesPosition[ i ];
+ _boxMorphTargets.setFromBufferAttribute( morphAttribute );
- }
+ _box.expandByPoint( _boxMorphTargets.min );
+ _box.expandByPoint( _boxMorphTargets.max );
}
- box.getCenter( center );
+ }
- // second, try to find a boundingSphere with a radius smaller than the
- // boundingSphere of the boundingBox: sqrt(3) smaller in the best case
+ _box.getCenter( center );
- var maxRadiusSq = 0;
+ // second, try to find a boundingSphere with a radius smaller than the
+ // boundingSphere of the boundingBox: sqrt(3) smaller in the best case
- for ( var i = 0, il = position.count; i < il; i ++ ) {
+ var maxRadiusSq = 0;
- vector.fromBufferAttribute( position, i );
+ for ( var i = 0, il = position.count; i < il; i ++ ) {
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
+ _vector.fromBufferAttribute( position, i );
- }
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );
- // process morph attributes if present
+ }
- if ( morphAttributesPosition ) {
+ // process morph attributes if present
- for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+ if ( morphAttributesPosition ) {
- var morphAttribute = morphAttributesPosition[ i ];
+ for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
- for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) {
+ var morphAttribute = morphAttributesPosition[ i ];
- vector.fromBufferAttribute( morphAttribute, j );
+ for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) {
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
+ _vector.fromBufferAttribute( morphAttribute, j );
- }
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );
}
}
- this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
+ }
- if ( isNaN( this.boundingSphere.radius ) ) {
+ this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
- console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this );
+ if ( isNaN( this.boundingSphere.radius ) ) {
- }
+ console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this );
}
- };
+ }
- }(),
+ },
computeFaceNormals: function () {
@@ -900,27 +877,23 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
normalizeNormals: function () {
- var vector = new Vector3();
+ if ( _vector === undefined ) _vector = new Vector3();
- return function normalizeNormals() {
+ var normals = this.attributes.normal;
- var normals = this.attributes.normal;
+ for ( var i = 0, il = normals.count; i < il; i ++ ) {
- for ( var i = 0, il = normals.count; i < il; i ++ ) {
+ _vector.x = normals.getX( i );
+ _vector.y = normals.getY( i );
+ _vector.z = normals.getZ( i );
- vector.x = normals.getX( i );
- vector.y = normals.getY( i );
- vector.z = normals.getZ( i );
+ _vector.normalize();
- vector.normalize();
+ normals.setXYZ( i, _vector.x, _vector.y, _vector.z );
- normals.setXYZ( i, vector.x, vector.y, vector.z );
-
- }
-
- };
+ }
- }(),
+ },
toNonIndexed: function () {
| true |
Other | mrdoob | three.js | 518d2463af8cd73a6c21137728493ff98124f857.json | Remove remaining IIFEs from core. | src/core/Geometry.js | @@ -19,11 +19,12 @@ import { _Math } from '../math/Math.js';
* @author bhouston / http://clara.io
*/
-var geometryId = 0; // Geometry uses even numbers as Id
+var _geometryId = 0; // Geometry uses even numbers as Id
+var _m1, _obj, _offset;
function Geometry() {
- Object.defineProperty( this, 'id', { value: geometryId += 2 } );
+ Object.defineProperty( this, 'id', { value: _geometryId += 2 } );
this.uuid = _Math.generateUUID();
@@ -107,111 +108,89 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
},
- rotateX: function () {
+ rotateX: function ( angle ) {
// rotate geometry around world x-axis
- var m1 = new Matrix4();
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- return function rotateX( angle ) {
+ _m1.makeRotationX( angle );
- m1.makeRotationX( angle );
+ this.applyMatrix( _m1 );
- this.applyMatrix( m1 );
-
- return this;
-
- };
+ return this;
- }(),
+ },
- rotateY: function () {
+ rotateY: function ( angle ) {
// rotate geometry around world y-axis
- var m1 = new Matrix4();
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- return function rotateY( angle ) {
+ _m1.makeRotationY( angle );
- m1.makeRotationY( angle );
+ this.applyMatrix( _m1 );
- this.applyMatrix( m1 );
-
- return this;
-
- };
+ return this;
- }(),
+ },
- rotateZ: function () {
+ rotateZ: function ( angle ) {
// rotate geometry around world z-axis
- var m1 = new Matrix4();
-
- return function rotateZ( angle ) {
-
- m1.makeRotationZ( angle );
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- this.applyMatrix( m1 );
+ _m1.makeRotationZ( angle );
- return this;
+ this.applyMatrix( _m1 );
- };
+ return this;
- }(),
+ },
- translate: function () {
+ translate: function ( x, y, z ) {
// translate geometry
- var m1 = new Matrix4();
-
- return function translate( x, y, z ) {
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- m1.makeTranslation( x, y, z );
+ _m1.makeTranslation( x, y, z );
- this.applyMatrix( m1 );
+ this.applyMatrix( _m1 );
- return this;
-
- };
+ return this;
- }(),
+ },
- scale: function () {
+ scale: function ( x, y, z ) {
// scale geometry
- var m1 = new Matrix4();
-
- return function scale( x, y, z ) {
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- m1.makeScale( x, y, z );
+ _m1.makeScale( x, y, z );
- this.applyMatrix( m1 );
+ this.applyMatrix( _m1 );
- return this;
-
- };
-
- }(),
+ return this;
- lookAt: function () {
+ },
- var obj = new Object3D();
+ lookAt: function ( vector ) {
- return function lookAt( vector ) {
+ if ( _obj === undefined ) _obj = new Object3D();
- obj.lookAt( vector );
+ _obj.lookAt( vector );
- obj.updateMatrix();
+ _obj.updateMatrix();
- this.applyMatrix( obj.matrix );
+ this.applyMatrix( _obj.matrix );
- };
+ return this;
- }(),
+ },
fromBufferGeometry: function ( geometry ) {
@@ -348,21 +327,17 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
center: function () {
- var offset = new Vector3();
-
- return function center() {
-
- this.computeBoundingBox();
+ if ( _offset === undefined ) _offset = new Vector3();
- this.boundingBox.getCenter( offset ).negate();
+ this.computeBoundingBox();
- this.translate( offset.x, offset.y, offset.z );
+ this.boundingBox.getCenter( _offset ).negate();
- return this;
+ this.translate( _offset.x, _offset.y, _offset.z );
- };
+ return this;
- }(),
+ },
normalize: function () {
| true |
Other | mrdoob | three.js | 518d2463af8cd73a6c21137728493ff98124f857.json | Remove remaining IIFEs from core. | src/core/Object3D.js | @@ -16,11 +16,14 @@ import { TrianglesDrawMode } from '../constants.js';
* @author elephantatwork / www.elephantatwork.ch
*/
-var object3DId = 0;
+var _object3DId = 0;
+var _m1, _q1, _v1;
+var _xAxis, _yAxis, _zAxis;
+var _target, _position, _scale, _quaternion;
function Object3D() {
- Object.defineProperty( this, 'id', { value: object3DId ++ } );
+ Object.defineProperty( this, 'id', { value: _object3DId ++ } );
this.uuid = _Math.generateUUID();
@@ -160,204 +163,164 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
},
- rotateOnAxis: function () {
+ rotateOnAxis: function ( axis, angle ) {
// rotate object on axis in object space
// axis is assumed to be normalized
- var q1 = new Quaternion();
+ if ( _q1 === undefined ) _q1 = new Quaternion();
- return function rotateOnAxis( axis, angle ) {
+ _q1.setFromAxisAngle( axis, angle );
- q1.setFromAxisAngle( axis, angle );
+ this.quaternion.multiply( _q1 );
- this.quaternion.multiply( q1 );
-
- return this;
-
- };
+ return this;
- }(),
+ },
- rotateOnWorldAxis: function () {
+ rotateOnWorldAxis: function ( axis, angle ) {
// rotate object on axis in world space
// axis is assumed to be normalized
// method assumes no rotated parent
- var q1 = new Quaternion();
-
- return function rotateOnWorldAxis( axis, angle ) {
-
- q1.setFromAxisAngle( axis, angle );
-
- this.quaternion.premultiply( q1 );
-
- return this;
-
- };
-
- }(),
-
- rotateX: function () {
-
- var v1 = new Vector3( 1, 0, 0 );
+ if ( _q1 === undefined ) _q1 = new Quaternion();
- return function rotateX( angle ) {
+ _q1.setFromAxisAngle( axis, angle );
- return this.rotateOnAxis( v1, angle );
+ this.quaternion.premultiply( _q1 );
- };
+ return this;
- }(),
+ },
- rotateY: function () {
+ rotateX: function ( angle ) {
- var v1 = new Vector3( 0, 1, 0 );
+ if ( _xAxis === undefined ) _xAxis = new Vector3( 1, 0, 0 );
- return function rotateY( angle ) {
+ return this.rotateOnAxis( _xAxis, angle );
- return this.rotateOnAxis( v1, angle );
+ },
- };
+ rotateY: function ( angle ) {
- }(),
+ if ( _yAxis === undefined ) _yAxis = new Vector3( 0, 1, 0 );
- rotateZ: function () {
+ return this.rotateOnAxis( _yAxis, angle );
- var v1 = new Vector3( 0, 0, 1 );
+ },
- return function rotateZ( angle ) {
+ rotateZ: function ( angle ) {
- return this.rotateOnAxis( v1, angle );
+ if ( _zAxis === undefined ) _zAxis = new Vector3( 0, 0, 1 );
- };
+ return this.rotateOnAxis( _zAxis, angle );
- }(),
+ },
- translateOnAxis: function () {
+ translateOnAxis: function ( axis, distance ) {
// translate object by distance along axis in object space
// axis is assumed to be normalized
- var v1 = new Vector3();
-
- return function translateOnAxis( axis, distance ) {
-
- v1.copy( axis ).applyQuaternion( this.quaternion );
-
- this.position.add( v1.multiplyScalar( distance ) );
-
- return this;
-
- };
-
- }(),
-
- translateX: function () {
+ if ( _v1 === undefined ) _v1 = new Vector3();
- var v1 = new Vector3( 1, 0, 0 );
+ _v1.copy( axis ).applyQuaternion( this.quaternion );
- return function translateX( distance ) {
+ this.position.add( _v1.multiplyScalar( distance ) );
- return this.translateOnAxis( v1, distance );
-
- };
+ return this;
- }(),
+ },
- translateY: function () {
+ translateX: function ( distance ) {
- var v1 = new Vector3( 0, 1, 0 );
+ if ( _xAxis === undefined ) _xAxis = new Vector3( 1, 0, 0 );
- return function translateY( distance ) {
+ return this.translateOnAxis( _xAxis, distance );
- return this.translateOnAxis( v1, distance );
+ },
- };
+ translateY: function ( distance ) {
- }(),
+ if ( _yAxis === undefined ) _yAxis = new Vector3( 0, 1, 0 );
- translateZ: function () {
+ return this.translateOnAxis( _yAxis, distance );
- var v1 = new Vector3( 0, 0, 1 );
+ },
- return function translateZ( distance ) {
+ translateZ: function ( distance ) {
- return this.translateOnAxis( v1, distance );
+ if ( _zAxis === undefined ) _zAxis = new Vector3( 0, 0, 1 );
- };
+ return this.translateOnAxis( _zAxis, distance );
- }(),
+ },
localToWorld: function ( vector ) {
return vector.applyMatrix4( this.matrixWorld );
},
- worldToLocal: function () {
-
- var m1 = new Matrix4();
-
- return function worldToLocal( vector ) {
+ worldToLocal: function ( vector ) {
- return vector.applyMatrix4( m1.getInverse( this.matrixWorld ) );
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- };
+ return vector.applyMatrix4( _m1.getInverse( this.matrixWorld ) );
- }(),
+ },
- lookAt: function () {
+ lookAt: function ( x, y, z ) {
// This method does not support objects having non-uniformly-scaled parent(s)
- var q1 = new Quaternion();
- var m1 = new Matrix4();
- var target = new Vector3();
- var position = new Vector3();
+ if ( _position === undefined ) {
- return function lookAt( x, y, z ) {
+ _q1 = new Quaternion();
+ _m1 = new Matrix4();
+ _target = new Vector3();
+ _position = new Vector3();
- if ( x.isVector3 ) {
+ }
- target.copy( x );
+ if ( x.isVector3 ) {
- } else {
+ _target.copy( x );
- target.set( x, y, z );
+ } else {
- }
+ _target.set( x, y, z );
- var parent = this.parent;
+ }
- this.updateWorldMatrix( true, false );
+ var parent = this.parent;
- position.setFromMatrixPosition( this.matrixWorld );
+ this.updateWorldMatrix( true, false );
- if ( this.isCamera || this.isLight ) {
+ _position.setFromMatrixPosition( this.matrixWorld );
- m1.lookAt( position, target, this.up );
+ if ( this.isCamera || this.isLight ) {
- } else {
+ _m1.lookAt( _position, _target, this.up );
- m1.lookAt( target, position, this.up );
+ } else {
- }
+ _m1.lookAt( _target, _position, this.up );
- this.quaternion.setFromRotationMatrix( m1 );
+ }
- if ( parent ) {
+ this.quaternion.setFromRotationMatrix( _m1 );
- m1.extractRotation( parent.matrixWorld );
- q1.setFromRotationMatrix( m1 );
- this.quaternion.premultiply( q1.inverse() );
+ if ( parent ) {
- }
+ _m1.extractRotation( parent.matrixWorld );
+ _q1.setFromRotationMatrix( _m1 );
+ this.quaternion.premultiply( _q1.inverse() );
- };
+ }
- }(),
+ },
add: function ( object ) {
@@ -432,37 +395,33 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
},
- attach: function () {
+ attach: function ( object ) {
// adds object as a child of this, while maintaining the object's world transform
- var m = new Matrix4();
+ if ( _m1 === undefined ) _m1 = new Matrix4();
- return function attach( object ) {
+ this.updateWorldMatrix( true, false );
- this.updateWorldMatrix( true, false );
+ _m1.getInverse( this.matrixWorld );
- m.getInverse( this.matrixWorld );
+ if ( object.parent !== null ) {
- if ( object.parent !== null ) {
-
- object.parent.updateWorldMatrix( true, false );
+ object.parent.updateWorldMatrix( true, false );
- m.multiply( object.parent.matrixWorld );
-
- }
+ _m1.multiply( object.parent.matrixWorld );
- object.applyMatrix( m );
+ }
- object.updateWorldMatrix( false, false );
+ object.applyMatrix( _m1 );
- this.add( object );
+ object.updateWorldMatrix( false, false );
- return this;
+ this.add( object );
- };
+ return this;
- }(),
+ },
getObjectById: function ( id ) {
@@ -512,53 +471,53 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
},
- getWorldQuaternion: function () {
+ getWorldQuaternion: function ( target ) {
- var position = new Vector3();
- var scale = new Vector3();
+ if ( _scale === undefined ) {
- return function getWorldQuaternion( target ) {
+ _position = new Vector3();
+ _scale = new Vector3();
- if ( target === undefined ) {
+ }
- console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );
- target = new Quaternion();
+ if ( target === undefined ) {
- }
+ console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );
+ target = new Quaternion();
- this.updateMatrixWorld( true );
+ }
- this.matrixWorld.decompose( position, target, scale );
+ this.updateMatrixWorld( true );
- return target;
+ this.matrixWorld.decompose( _position, target, _scale );
- };
+ return target;
- }(),
+ },
- getWorldScale: function () {
+ getWorldScale: function ( target ) {
- var position = new Vector3();
- var quaternion = new Quaternion();
+ if ( _quaternion === undefined ) {
- return function getWorldScale( target ) {
+ _position = new Vector3();
+ _quaternion = new Quaternion();
- if ( target === undefined ) {
+ }
- console.warn( 'THREE.Object3D: .getWorldScale() target is now required' );
- target = new Vector3();
+ if ( target === undefined ) {
- }
+ console.warn( 'THREE.Object3D: .getWorldScale() target is now required' );
+ target = new Vector3();
- this.updateMatrixWorld( true );
+ }
- this.matrixWorld.decompose( position, quaternion, target );
+ this.updateMatrixWorld( true );
- return target;
+ this.matrixWorld.decompose( _position, _quaternion, target );
- };
+ return target;
- }(),
+ },
getWorldDirection: function ( target ) {
| true |
Other | mrdoob | three.js | 518d2463af8cd73a6c21137728493ff98124f857.json | Remove remaining IIFEs from core. | src/loaders/Loader.js | @@ -24,6 +24,8 @@ import { Color } from '../math/Color.js';
* @author alteredq / http://alteredqualia.com/
*/
+var _BlendingMode, _color, _textureLoader, _materialLoader;
+
function Loader() {}
Loader.Handlers = {
@@ -83,260 +85,260 @@ Object.assign( Loader.prototype, {
},
- createMaterial: ( function () {
+ createMaterial: function ( m, texturePath, crossOrigin ) {
- var BlendingMode = {
- NoBlending: NoBlending,
- NormalBlending: NormalBlending,
- AdditiveBlending: AdditiveBlending,
- SubtractiveBlending: SubtractiveBlending,
- MultiplyBlending: MultiplyBlending,
- CustomBlending: CustomBlending
- };
+ if ( _materialLoader === undefined ) {
- var color = new Color();
- var textureLoader = new TextureLoader();
- var materialLoader = new MaterialLoader();
+ _BlendingMode = {
+ NoBlending: NoBlending,
+ NormalBlending: NormalBlending,
+ AdditiveBlending: AdditiveBlending,
+ SubtractiveBlending: SubtractiveBlending,
+ MultiplyBlending: MultiplyBlending,
+ CustomBlending: CustomBlending
+ };
- return function createMaterial( m, texturePath, crossOrigin ) {
+ _color = new Color();
+ _textureLoader = new TextureLoader();
+ _materialLoader = new MaterialLoader();
+
+ }
- // convert from old material format
+ // convert from old material format
- var textures = {};
+ var textures = {};
- function loadTexture( path, repeat, offset, wrap, anisotropy ) {
+ //
- var fullPath = texturePath + path;
- var loader = Loader.Handlers.get( fullPath );
+ var json = {
+ uuid: _Math.generateUUID(),
+ type: 'MeshLambertMaterial'
+ };
- var texture;
+ for ( var name in m ) {
+
+ var value = m[ name ];
+
+ switch ( name ) {
+
+ case 'DbgColor':
+ case 'DbgIndex':
+ case 'opticalDensity':
+ case 'illumination':
+ break;
+ case 'DbgName':
+ json.name = value;
+ break;
+ case 'blending':
+ json.blending = _BlendingMode[ value ];
+ break;
+ case 'colorAmbient':
+ case 'mapAmbient':
+ console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' );
+ break;
+ case 'colorDiffuse':
+ json.color = _color.fromArray( value ).getHex();
+ break;
+ case 'colorSpecular':
+ json.specular = _color.fromArray( value ).getHex();
+ break;
+ case 'colorEmissive':
+ json.emissive = _color.fromArray( value ).getHex();
+ break;
+ case 'specularCoef':
+ json.shininess = value;
+ break;
+ case 'shading':
+ if ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial';
+ if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial';
+ if ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial';
+ break;
+ case 'mapDiffuse':
+ json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy, textures, texturePath, crossOrigin );
+ break;
+ case 'mapDiffuseRepeat':
+ case 'mapDiffuseOffset':
+ case 'mapDiffuseWrap':
+ case 'mapDiffuseAnisotropy':
+ break;
+ case 'mapEmissive':
+ json.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy, textures, texturePath, crossOrigin );
+ break;
+ case 'mapEmissiveRepeat':
+ case 'mapEmissiveOffset':
+ case 'mapEmissiveWrap':
+ case 'mapEmissiveAnisotropy':
+ break;
+ case 'mapLight':
+ json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy, textures, texturePath, crossOrigin );
+ break;
+ case 'mapLightRepeat':
+ case 'mapLightOffset':
+ case 'mapLightWrap':
+ case 'mapLightAnisotropy':
+ break;
+ case 'mapAO':
+ json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy, textures, texturePath, crossOrigin );
+ break;
+ case 'mapAORepeat':
+ case 'mapAOOffset':
+ case 'mapAOWrap':
+ case 'mapAOAnisotropy':
+ break;
+ case 'mapBump':
+ json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy, textures, texturePath, crossOrigin );
+ break;
+ case 'mapBumpScale':
+ json.bumpScale = value;
+ break;
+ case 'mapBumpRepeat':
+ case 'mapBumpOffset':
+ case 'mapBumpWrap':
+ case 'mapBumpAnisotropy':
+ break;
+ case 'mapNormal':
+ json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy, textures, texturePath, crossOrigin );
+ break;
+ case 'mapNormalFactor':
+ json.normalScale = value;
+ break;
+ case 'mapNormalRepeat':
+ case 'mapNormalOffset':
+ case 'mapNormalWrap':
+ case 'mapNormalAnisotropy':
+ break;
+ case 'mapSpecular':
+ json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy, textures, texturePath, crossOrigin );
+ break;
+ case 'mapSpecularRepeat':
+ case 'mapSpecularOffset':
+ case 'mapSpecularWrap':
+ case 'mapSpecularAnisotropy':
+ break;
+ case 'mapMetalness':
+ json.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy, textures, texturePath, crossOrigin );
+ break;
+ case 'mapMetalnessRepeat':
+ case 'mapMetalnessOffset':
+ case 'mapMetalnessWrap':
+ case 'mapMetalnessAnisotropy':
+ break;
+ case 'mapRoughness':
+ json.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy, textures, texturePath, crossOrigin );
+ break;
+ case 'mapRoughnessRepeat':
+ case 'mapRoughnessOffset':
+ case 'mapRoughnessWrap':
+ case 'mapRoughnessAnisotropy':
+ break;
+ case 'mapAlpha':
+ json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy, textures, texturePath, crossOrigin );
+ break;
+ case 'mapAlphaRepeat':
+ case 'mapAlphaOffset':
+ case 'mapAlphaWrap':
+ case 'mapAlphaAnisotropy':
+ break;
+ case 'flipSided':
+ json.side = BackSide;
+ break;
+ case 'doubleSided':
+ json.side = DoubleSide;
+ break;
+ case 'transparency':
+ console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' );
+ json.opacity = value;
+ break;
+ case 'depthTest':
+ case 'depthWrite':
+ case 'colorWrite':
+ case 'opacity':
+ case 'reflectivity':
+ case 'transparent':
+ case 'visible':
+ case 'wireframe':
+ json[ name ] = value;
+ break;
+ case 'vertexColors':
+ if ( value === true ) json.vertexColors = VertexColors;
+ if ( value === 'face' ) json.vertexColors = FaceColors;
+ break;
+ default:
+ console.error( 'THREE.Loader.createMaterial: Unsupported', name, value );
+ break;
- if ( loader !== null ) {
+ }
- texture = loader.load( fullPath );
+ }
- } else {
+ if ( json.type === 'MeshBasicMaterial' ) delete json.emissive;
+ if ( json.type !== 'MeshPhongMaterial' ) delete json.specular;
- textureLoader.setCrossOrigin( crossOrigin );
- texture = textureLoader.load( fullPath );
+ if ( json.opacity < 1 ) json.transparent = true;
- }
+ _materialLoader.setTextures( textures );
- if ( repeat !== undefined ) {
+ return _materialLoader.parse( json );
- texture.repeat.fromArray( repeat );
+ }
- if ( repeat[ 0 ] !== 1 ) texture.wrapS = RepeatWrapping;
- if ( repeat[ 1 ] !== 1 ) texture.wrapT = RepeatWrapping;
+} );
- }
+function loadTexture( path, repeat, offset, wrap, anisotropy, textures, texturePath, crossOrigin ) {
- if ( offset !== undefined ) {
+ var fullPath = texturePath + path;
+ var loader = Loader.Handlers.get( fullPath );
- texture.offset.fromArray( offset );
+ var texture;
- }
+ if ( loader !== null ) {
- if ( wrap !== undefined ) {
+ texture = loader.load( fullPath );
- if ( wrap[ 0 ] === 'repeat' ) texture.wrapS = RepeatWrapping;
- if ( wrap[ 0 ] === 'mirror' ) texture.wrapS = MirroredRepeatWrapping;
+ } else {
- if ( wrap[ 1 ] === 'repeat' ) texture.wrapT = RepeatWrapping;
- if ( wrap[ 1 ] === 'mirror' ) texture.wrapT = MirroredRepeatWrapping;
+ _textureLoader.setCrossOrigin( crossOrigin );
+ texture = _textureLoader.load( fullPath );
- }
+ }
- if ( anisotropy !== undefined ) {
+ if ( repeat !== undefined ) {
- texture.anisotropy = anisotropy;
+ texture.repeat.fromArray( repeat );
- }
+ if ( repeat[ 0 ] !== 1 ) texture.wrapS = RepeatWrapping;
+ if ( repeat[ 1 ] !== 1 ) texture.wrapT = RepeatWrapping;
- var uuid = _Math.generateUUID();
+ }
- textures[ uuid ] = texture;
+ if ( offset !== undefined ) {
- return uuid;
+ texture.offset.fromArray( offset );
- }
+ }
- //
+ if ( wrap !== undefined ) {
- var json = {
- uuid: _Math.generateUUID(),
- type: 'MeshLambertMaterial'
- };
+ if ( wrap[ 0 ] === 'repeat' ) texture.wrapS = RepeatWrapping;
+ if ( wrap[ 0 ] === 'mirror' ) texture.wrapS = MirroredRepeatWrapping;
- for ( var name in m ) {
-
- var value = m[ name ];
-
- switch ( name ) {
-
- case 'DbgColor':
- case 'DbgIndex':
- case 'opticalDensity':
- case 'illumination':
- break;
- case 'DbgName':
- json.name = value;
- break;
- case 'blending':
- json.blending = BlendingMode[ value ];
- break;
- case 'colorAmbient':
- case 'mapAmbient':
- console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' );
- break;
- case 'colorDiffuse':
- json.color = color.fromArray( value ).getHex();
- break;
- case 'colorSpecular':
- json.specular = color.fromArray( value ).getHex();
- break;
- case 'colorEmissive':
- json.emissive = color.fromArray( value ).getHex();
- break;
- case 'specularCoef':
- json.shininess = value;
- break;
- case 'shading':
- if ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial';
- if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial';
- if ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial';
- break;
- case 'mapDiffuse':
- json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy );
- break;
- case 'mapDiffuseRepeat':
- case 'mapDiffuseOffset':
- case 'mapDiffuseWrap':
- case 'mapDiffuseAnisotropy':
- break;
- case 'mapEmissive':
- json.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy );
- break;
- case 'mapEmissiveRepeat':
- case 'mapEmissiveOffset':
- case 'mapEmissiveWrap':
- case 'mapEmissiveAnisotropy':
- break;
- case 'mapLight':
- json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy );
- break;
- case 'mapLightRepeat':
- case 'mapLightOffset':
- case 'mapLightWrap':
- case 'mapLightAnisotropy':
- break;
- case 'mapAO':
- json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy );
- break;
- case 'mapAORepeat':
- case 'mapAOOffset':
- case 'mapAOWrap':
- case 'mapAOAnisotropy':
- break;
- case 'mapBump':
- json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy );
- break;
- case 'mapBumpScale':
- json.bumpScale = value;
- break;
- case 'mapBumpRepeat':
- case 'mapBumpOffset':
- case 'mapBumpWrap':
- case 'mapBumpAnisotropy':
- break;
- case 'mapNormal':
- json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy );
- break;
- case 'mapNormalFactor':
- json.normalScale = value;
- break;
- case 'mapNormalRepeat':
- case 'mapNormalOffset':
- case 'mapNormalWrap':
- case 'mapNormalAnisotropy':
- break;
- case 'mapSpecular':
- json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy );
- break;
- case 'mapSpecularRepeat':
- case 'mapSpecularOffset':
- case 'mapSpecularWrap':
- case 'mapSpecularAnisotropy':
- break;
- case 'mapMetalness':
- json.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy );
- break;
- case 'mapMetalnessRepeat':
- case 'mapMetalnessOffset':
- case 'mapMetalnessWrap':
- case 'mapMetalnessAnisotropy':
- break;
- case 'mapRoughness':
- json.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy );
- break;
- case 'mapRoughnessRepeat':
- case 'mapRoughnessOffset':
- case 'mapRoughnessWrap':
- case 'mapRoughnessAnisotropy':
- break;
- case 'mapAlpha':
- json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy );
- break;
- case 'mapAlphaRepeat':
- case 'mapAlphaOffset':
- case 'mapAlphaWrap':
- case 'mapAlphaAnisotropy':
- break;
- case 'flipSided':
- json.side = BackSide;
- break;
- case 'doubleSided':
- json.side = DoubleSide;
- break;
- case 'transparency':
- console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' );
- json.opacity = value;
- break;
- case 'depthTest':
- case 'depthWrite':
- case 'colorWrite':
- case 'opacity':
- case 'reflectivity':
- case 'transparent':
- case 'visible':
- case 'wireframe':
- json[ name ] = value;
- break;
- case 'vertexColors':
- if ( value === true ) json.vertexColors = VertexColors;
- if ( value === 'face' ) json.vertexColors = FaceColors;
- break;
- default:
- console.error( 'THREE.Loader.createMaterial: Unsupported', name, value );
- break;
-
- }
+ if ( wrap[ 1 ] === 'repeat' ) texture.wrapT = RepeatWrapping;
+ if ( wrap[ 1 ] === 'mirror' ) texture.wrapT = MirroredRepeatWrapping;
- }
+ }
- if ( json.type === 'MeshBasicMaterial' ) delete json.emissive;
- if ( json.type !== 'MeshPhongMaterial' ) delete json.specular;
+ if ( anisotropy !== undefined ) {
- if ( json.opacity < 1 ) json.transparent = true;
+ texture.anisotropy = anisotropy;
- materialLoader.setTextures( textures );
+ }
- return materialLoader.parse( json );
+ var uuid = _Math.generateUUID();
- };
+ textures[ uuid ] = texture;
- } )()
+ return uuid;
-} );
+}
export { Loader }; | true |
Other | mrdoob | three.js | 518d2463af8cd73a6c21137728493ff98124f857.json | Remove remaining IIFEs from core. | src/polyfills.js | @@ -55,44 +55,40 @@ if ( Object.assign === undefined ) {
// Missing in IE
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
- ( function () {
+ Object.assign = function ( target ) {
- Object.assign = function ( target ) {
+ 'use strict';
- 'use strict';
+ if ( target === undefined || target === null ) {
- if ( target === undefined || target === null ) {
+ throw new TypeError( 'Cannot convert undefined or null to object' );
- throw new TypeError( 'Cannot convert undefined or null to object' );
-
- }
-
- var output = Object( target );
+ }
- for ( var index = 1; index < arguments.length; index ++ ) {
+ var output = Object( target );
- var source = arguments[ index ];
+ for ( var index = 1; index < arguments.length; index ++ ) {
- if ( source !== undefined && source !== null ) {
+ var source = arguments[ index ];
- for ( var nextKey in source ) {
+ if ( source !== undefined && source !== null ) {
- if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) {
+ for ( var nextKey in source ) {
- output[ nextKey ] = source[ nextKey ];
+ if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) {
- }
+ output[ nextKey ] = source[ nextKey ];
}
}
}
- return output;
+ }
- };
+ return output;
- } )();
+ };
} | true |
Other | mrdoob | three.js | 6df176d3f014effff3436f514ab9f5a03e0e80b4.json | fix minor style issue | examples/js/objects/Sky.js | @@ -40,7 +40,7 @@ THREE.Sky.SkyShader = {
"mieCoefficient": { value: 0.005 },
"mieDirectionalG": { value: 0.8 },
"sunPosition": { value: new THREE.Vector3() },
- "up": { value: new THREE.Vector3(0, 1, 0) }
+ "up": { value: new THREE.Vector3( 0, 1, 0 ) }
},
vertexShader: [ | true |
Other | mrdoob | three.js | 6df176d3f014effff3436f514ab9f5a03e0e80b4.json | fix minor style issue | examples/jsm/objects/Sky.js | @@ -49,7 +49,7 @@ Sky.SkyShader = {
"mieCoefficient": { value: 0.005 },
"mieDirectionalG": { value: 0.8 },
"sunPosition": { value: new Vector3() },
- "up": { value: new Vector3(0, 1, 0) }
+ "up": { value: new Vector3( 0, 1, 0 ) }
},
vertexShader: [ | true |
Other | mrdoob | three.js | cbf555d24250ed7d319edd3ad71c3db06e40af84.json | add bias example and update prem texture | examples/webgl_materials_nodes.html | @@ -71,63 +71,56 @@
}
- var cubemap = function () {
+ var premTexture, pmremCube, pmremGenerator, pmremCubeUVPacker, premSize = 1024;
- var path = "textures/cube/Park2/";
- var format = '.jpg';
- var urls = [
- path + 'posx' + format, path + 'negx' + format,
- path + 'posy' + format, path + 'negy' + format,
- path + 'posz' + format, path + 'negz' + format
- ];
+ function updatePREM( textureCube ) {
- var textureCube = new THREE.CubeTextureLoader().load( urls );
- textureCube.format = THREE.RGBFormat;
+ pmremCube = pmremCube || textureCube;
- library[ textureCube.uuid ] = textureCube;
+ if ( ! pmremCube || ! renderer ) return;
- return textureCube;
+ var minFilter = pmremCube.minFilter;
+ var magFilter = pmremCube.magFilter;
+ var generateMipmaps = pmremCube.generateMipmaps;
- }();
+ pmremGenerator = new PMREMGenerator( pmremCube, undefined, premSize / 4 );
+ pmremGenerator.update( renderer );
- function generatePREM( cubeMap, textureSize ) {
+ pmremCubeUVPacker = new PMREMCubeUVPacker( pmremGenerator.cubeLods );
+ pmremCubeUVPacker.update( renderer );
- textureSize = textureSize || 1024;
+ pmremCube.minFilter = minFilter;
+ pmremCube.magFilter = magFilter;
+ pmremCube.generateMipmaps = pmremCube.generateMipmaps;
+ pmremCube.needsUpdate = true;
- var pmremGenerator = new PMREMGenerator( cubeMap, undefined, textureSize / 4 );
- pmremGenerator.update( renderer );
+ premTexture = pmremCubeUVPacker.CubeUVRenderTarget.texture
- var pmremCubeUVPacker = new PMREMCubeUVPacker( pmremGenerator.cubeLods );
- pmremCubeUVPacker.update( renderer );
+ library[ premTexture.uuid ] = premTexture;
pmremGenerator.dispose();
pmremCubeUVPacker.dispose();
- return pmremCubeUVPacker.CubeUVRenderTarget.texture;
-
}
- var premTexture;
-
- function getPREM( callback, textureSize ) {
-
- if ( premTexture ) return callback( premTexture );
-
- var hdrUrls = [ 'px.hdr', 'nx.hdr', 'py.hdr', 'ny.hdr', 'pz.hdr', 'nz.hdr' ];
- var hdrCubeMap = new HDRCubeTextureLoader()
- .setPath( './textures/cube/pisaHDR/' )
- .setDataType( THREE.UnsignedByteType )
- .load( hdrUrls, function () {
+ var cubemap = function () {
- premTexture = generatePREM( hdrCubeMap, textureSize );
+ var path = "textures/cube/Park2/";
+ var format = '.jpg';
+ var urls = [
+ path + 'posx' + format, path + 'negx' + format,
+ path + 'posy' + format, path + 'negy' + format,
+ path + 'posz' + format, path + 'negz' + format
+ ];
- library[ premTexture.uuid ] = premTexture;
+ var textureCube = new THREE.CubeTextureLoader().load( urls, updatePREM );
+ textureCube.format = THREE.RGBFormat;
- callback( premTexture );
+ library[ textureCube.uuid ] = textureCube;
- } );
+ return textureCube;
- }
+ }();
window.addEventListener( 'load', init );
@@ -176,6 +169,8 @@
library[ camera.uuid ] = camera;
library[ mesh.uuid ] = mesh;
+ updatePREM();
+
window.addEventListener( 'resize', onWindowResize, false );
updateMaterial();
@@ -226,6 +221,7 @@
'adv / expression': 'expression',
'adv / sss': 'sss',
'adv / translucent': 'translucent',
+ 'adv / bias': 'bias',
'node / position': 'node-position',
'node / normal': 'node-normal',
'node / reflect': 'node-reflect',
@@ -504,14 +500,8 @@
mtl.normal = new Nodes.NormalMapNode( new Nodes.TextureNode( getTexture( "grassNormal" ) ) );
mtl.normal.scale = normalMask;
- getPREM(function(texture) {
-
- var envNode = new Nodes.TextureCubeNode( new Nodes.TextureNode( texture ) );
-
- mtl.environment = new Nodes.OperatorNode( envNode, intensity, Nodes.OperatorNode.MUL );
- mtl.needsUpdate = true;
-
- });
+ var envNode = new Nodes.TextureCubeNode( new Nodes.TextureNode( premTexture ) );
+ mtl.environment = new Nodes.OperatorNode( envNode, intensity, Nodes.OperatorNode.MUL );
// GUI
@@ -587,18 +577,13 @@
mtl.normal = new Nodes.NormalMapNode( new Nodes.TextureNode( getTexture( "grassNormal" ) ) );
mtl.normal.scale = normalScale;
- getPREM(function(texture) {
-
- var envNode = new Nodes.TextureCubeNode( new Nodes.TextureNode( texture ) );
+ var envNode = new Nodes.TextureCubeNode( new Nodes.TextureNode( premTexture ) );
- var subSlotNode = new Nodes.SubSlotNode();
- subSlotNode.slots['radiance'] = new Nodes.OperatorNode( radiance, envNode, Nodes.OperatorNode.MUL );
- subSlotNode.slots['irradiance'] = new Nodes.OperatorNode( irradiance, envNode, Nodes.OperatorNode.MUL );
+ var subSlotNode = new Nodes.SubSlotNode();
+ subSlotNode.slots['radiance'] = new Nodes.OperatorNode( radiance, envNode, Nodes.OperatorNode.MUL );
+ subSlotNode.slots['irradiance'] = new Nodes.OperatorNode( irradiance, envNode, Nodes.OperatorNode.MUL );
- mtl.environment = subSlotNode;
- mtl.needsUpdate = true;
-
- });
+ mtl.environment = subSlotNode
// GUI
@@ -2483,6 +2468,79 @@
break;
+ case 'bias':
+
+ // PREREQUISITES
+
+ var image = cubemap.image[ 0 ];
+ var maxMIPLevel = image !== undefined ? Math.log( Math.max( image.width, image.height ) ) * Math.LOG2E : 0;
+
+ // MATERIAL
+
+ var bias = new Nodes.FloatNode( .5 );
+ var mipsBias = new Nodes.OperatorNode( bias, new Nodes.FloatNode( maxMIPLevel ), Nodes.OperatorNode.MUL );
+
+ mtl = new Nodes.PhongNodeMaterial();
+ mtl.color.value.setHex( 0xFFFFFF );
+
+ function biasMode( val ) {
+
+ switch( val ) {
+
+ case 'prem':
+
+ mtl.color = new Nodes.TextureCubeNode( new Nodes.TextureNode( premTexture ), undefined, undefined, bias );
+
+ break;
+
+ case 'lod':
+
+ var textureCubeFunction = new Nodes.FunctionNode( [
+ "vec4 textureCubeFunction( samplerCube texture, vec3 uv, float bias ) {",
+ " return textureCubeLodEXT( texture, uv, bias );",
+ "}"
+ ].join( "\n" ), undefined, { shaderTextureLOD: true } );
+
+ mtl.color = new Nodes.FunctionCallNode( textureCubeFunction, [ new Nodes.CubeTextureNode( cubemap ), new Nodes.ReflectNode(), mipsBias ] );
+
+ break;
+
+ case 'basic':
+
+ var textureCubeFunction = new Nodes.FunctionNode( [
+ "vec4 textureCubeFunction( samplerCube texture, vec3 uv, float bias ) {",
+ " return textureCube( texture, uv, bias );",
+ "}"
+ ].join( "\n" ) );
+
+ mtl.color = new Nodes.FunctionCallNode( textureCubeFunction, [ new Nodes.CubeTextureNode( cubemap ), new Nodes.ReflectNode(), mipsBias ] );
+
+ break;
+
+ }
+
+ mtl.needsUpdate = true;
+
+ }
+
+ biasMode( 'prem' );
+
+ // GUI
+
+ addGui( 'scope', {
+ PREM: 'prem',
+ LOD: 'lod',
+ BASIC: 'basic'
+ }, biasMode );
+
+ addGui( 'bias', bias.value, function ( val ) {
+
+ bias.value = val;
+
+ }, false, 0, 1 );
+
+ break;
+
case 'node-position':
// MATERIAL | false |
Other | mrdoob | three.js | 3ac3c1ee896d5cc511d3ffee4ba15883619b3e80.json | remove energyPreservation flags | examples/jsm/nodes/materials/nodes/StandardNode.js | @@ -34,8 +34,6 @@ StandardNode.prototype.build = function ( builder ) {
builder.define( this.clearCoat || this.clearCoatRoughness ? 'PHYSICAL' : 'STANDARD' );
- if ( this.energyPreservation ) builder.define( 'ENERGY_PRESERVATION' );
-
builder.requires.lights = true;
builder.extensions.shaderTextureLOD = true; | false |
Other | mrdoob | three.js | 070101a9b3ae3b971316b4ae82fa3fa28452c9b8.json | remove non-ENERGY_PRESERVATION code | src/materials/MeshStandardMaterial.js | @@ -44,8 +44,6 @@ import { Color } from '../math/Color.js';
* envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),
* envMapIntensity: <float>
*
- * energyPreservation: <bool>,
- *
* refractionRatio: <float>,
*
* wireframe: <boolean>,
@@ -101,8 +99,6 @@ function MeshStandardMaterial( parameters ) {
this.envMap = null;
this.envMapIntensity = 1.0;
- this.energyPreservation = true;
-
this.refractionRatio = 0.98;
this.wireframe = false;
@@ -165,8 +161,6 @@ MeshStandardMaterial.prototype.copy = function ( source ) {
this.envMap = source.envMap;
this.envMapIntensity = source.envMapIntensity;
- this.energyPreservation = source.energyPreservation;
-
this.refractionRatio = source.refractionRatio;
this.wireframe = source.wireframe; | true |
Other | mrdoob | three.js | 070101a9b3ae3b971316b4ae82fa3fa28452c9b8.json | remove non-ENERGY_PRESERVATION code | src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js | @@ -96,13 +96,6 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricC
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- // Defer to the IndirectSpecular function to compute
- // the indirectDiffuse if energy preservation is enabled.
- #ifndef ENERGY_PRESERVATION
-
- reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
-
- #endif
}
@@ -120,25 +113,18 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
// Both indirect specular and diffuse light accumulate here
// if energy preservation enabled, and PMREM provided.
- #if defined( ENERGY_PRESERVATION )
-
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
+ vec3 singleScattering = vec3( 0.0 );
+ vec3 multiScattering = vec3( 0.0 );
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
+ BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
- reflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;
- reflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
+ vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
- #else
-
- reflectedLight.indirectSpecular += clearCoatInv * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );
-
- #endif
+ reflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;
+ reflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;
+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
#ifndef STANDARD
| true |
Other | mrdoob | three.js | 070101a9b3ae3b971316b4ae82fa3fa28452c9b8.json | remove non-ENERGY_PRESERVATION code | src/renderers/webgl/WebGLProgram.js | @@ -522,8 +522,6 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters,
parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '',
- parameters.energyPreservation ? '#define ENERGY_PRESERVATION' : '',
-
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
parameters.logarithmicDepthBuffer && ( capabilities.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
| true |
Other | mrdoob | three.js | 070101a9b3ae3b971316b4ae82fa3fa28452c9b8.json | remove non-ENERGY_PRESERVATION code | src/renderers/webgl/WebGLPrograms.js | @@ -201,8 +201,6 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
toneMapping: renderer.toneMapping,
physicallyCorrectLights: renderer.physicallyCorrectLights,
- energyPreservation: material.energyPreservation,
-
premultipliedAlpha: material.premultipliedAlpha,
alphaTest: material.alphaTest, | true |
Other | mrdoob | three.js | 7247f04180e7ee9e5f0193470e589904ab17b009.json | Remove dup paragraph in disposing objects doc
I deleted a duplicate paragraph from the "How to dispose of objects" page in the docs. | docs/manual/en/introduction/How-to-dispose-of-objects.html | @@ -92,11 +92,6 @@ <h3>Does *three.js* provide information about the amount of cached objects?</h3>
in your application, it's a good idea to debug this property in order to easily identify a memory leak.
</p>
- <p>
- Internal resources for a texture are only allocated if the image has fully loaded. If you dispose a texture before the image was loaded,
- nothing happens. No resources were allocated so there is also no need for clean up.
- </p>
-
<h3>What happens when you call *dispose()* on a texture but the image is not loaded yet?</h3>
<p> | false |
Other | mrdoob | three.js | 5d073e1ef3a81b883f090adb09f103be79b79411.json | Remove triangulate function from typing
Function has already been removed from the codebase and is not part of the public API. | src/extras/ShapeUtils.d.ts | @@ -5,7 +5,6 @@ interface Vec2 {
export namespace ShapeUtils {
export function area( contour: Vec2[] ): number;
- export function triangulate( contour: Vec2[], indices: boolean ): number[];
export function triangulateShape( contour: Vec2[], holes: Vec2[] ): number[][];
export function isClockWise( pts: Vec2[] ): boolean;
} | false |
Other | mrdoob | three.js | ba248bcbf08c222413daf6341ecc7c9e1f8b3707.json | force context loss in renderer.dispose | src/renderers/WebGLRenderer.js | @@ -577,6 +577,8 @@ function WebGLRenderer( parameters ) {
animation.stop();
+ this.forceContextLoss();
+
};
// Events | false |
Other | mrdoob | three.js | 6f63ebba977a1851ff206d5603d074454342ad79.json | fix default side | examples/webgl_materials_nodes.html | @@ -725,9 +725,9 @@
}, false );
addGui( 'side', {
+ DoubleSided: THREE.DoubleSide,
FrontSided: THREE.FrontSide,
- BackSided: THREE.BackSide,
- DoubleSided: THREE.DoubleSide
+ BackSided: THREE.BackSide
}, function ( val ) {
defaultSide = Number( val ); | false |
Other | mrdoob | three.js | 6ee06c715587c498cac381727278adf4da34189c.json | Add default to textures | src/textures/DataTexture2DArray.js | @@ -9,7 +9,7 @@ function DataTexture2DArray( data, width, height, depth ) {
Texture.call( this, null );
- this.image = { data: data, width: width, height: height, depth: depth };
+ this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };
this.magFilter = NearestFilter;
this.minFilter = NearestFilter; | true |
Other | mrdoob | three.js | 6ee06c715587c498cac381727278adf4da34189c.json | Add default to textures | src/textures/DataTexture3D.js | @@ -17,7 +17,7 @@ function DataTexture3D( data, width, height, depth ) {
Texture.call( this, null );
- this.image = { data: data, width: width, height: height, depth: depth };
+ this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };
this.magFilter = NearestFilter;
this.minFilter = NearestFilter; | true |
Other | mrdoob | three.js | 9d324c9601f2fddcb86d1f09262db9a0998338c3.json | add quaternion tests | test/unit/src/math/Quaternion.tests.js | @@ -224,27 +224,119 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "x", ( assert ) => {
+ QUnit.test( "x", ( assert ) => {
+ var a = new Quaternion();
+ assert.ok(a.x === 0, "Passed!");
- assert.ok( false, "everything's gonna be alright" );
+ a = new Quaternion(1, 2, 3);
+ assert.ok(a.x === 1, "Passed!");
+
+ a = new Quaternion(4, 5, 6, 1);
+ assert.ok(a.x === 4, "Passed!");
+
+ a = new Quaternion(7, 8, 9);
+ a.x = 10;
+ assert.ok(a.x === 10, "Passed!");
+
+ a = new Quaternion(11, 12, 13);
+ var b = false;
+ a._onChange(function () {
+
+ b = true;
+
+ });
+ assert.ok(!b, "Passed!");
+ a.x = 14;
+ assert.ok(b, "Passed!");
+ assert.ok(a.x === 14, "Passed!");
} );
- QUnit.todo( "y", ( assert ) => {
+ QUnit.test( "y", ( assert ) => {
- assert.ok( false, "everything's gonna be alright" );
+ var a = new Quaternion();
+ assert.ok(a.y === 0, "Passed!");
+
+ a = new Quaternion(1, 2, 3);
+ assert.ok(a.y === 2, "Passed!");
+
+ a = new Quaternion(4, 5, 6, 1);
+ assert.ok(a.y === 5, "Passed!");
+
+ a = new Quaternion(7, 8, 9);
+ a.y = 10;
+ assert.ok(a.y === 10, "Passed!");
+
+ a = new Quaternion(11, 12, 13);
+ var b = false;
+ a._onChange(function () {
+
+ b = true;
+
+ });
+ assert.ok(!b, "Passed!");
+ a.y = 14;
+ assert.ok(b, "Passed!");
+ assert.ok(a.y === 14, "Passed!");
} );
- QUnit.todo( "z", ( assert ) => {
+ QUnit.test( "z", ( assert ) => {
- assert.ok( false, "everything's gonna be alright" );
+
+ var a = new Quaternion();
+ assert.ok(a.z === 0, "Passed!");
+
+ a = new Quaternion(1, 2, 3);
+ assert.ok(a.z === 3, "Passed!");
+
+ a = new Quaternion(4, 5, 6, 1);
+ assert.ok(a.z === 6, "Passed!");
+
+ a = new Quaternion(7, 8, 9);
+ a.z = 10;
+ assert.ok(a.z === 10, "Passed!");
+
+ a = new Quaternion(11, 12, 13);
+ var b = false;
+ a._onChange(function () {
+
+ b = true;
+
+ });
+ assert.ok(!b, "Passed!");
+ a.z = 14;
+ assert.ok(b, "Passed!");
+ assert.ok(a.z === 14, "Passed!");
} );
- QUnit.todo( "w", ( assert ) => {
+ QUnit.test( "w", ( assert ) => {
- assert.ok( false, "everything's gonna be alright" );
+ var a = new Quaternion();
+ assert.ok(a.w === 1, "Passed!");
+
+ a = new Quaternion(1, 2, 3);
+ assert.ok(a.w === 1, "Passed!");
+
+ a = new Quaternion(4, 5, 6, 1);
+ assert.ok(a.w === 1, "Passed!");
+
+ a = new Quaternion(7, 8, 9);
+ a.w = 10;
+ assert.ok(a.w === 10, "Passed!");
+
+ a = new Quaternion(11, 12, 13);
+ var b = false;
+ a._onChange(function () {
+
+ b = true;
+
+ });
+ assert.ok(!b, "Passed!");
+ a.w = 14;
+ assert.ok(b, "Passed!");
+ assert.ok(a.w === 14, "Passed!");
} );
| false |
Other | mrdoob | three.js | 416c109665f067237f6ce7dc1dfdbb0df088d104.json | remove unnessecary import | test/unit/src/math/Plane.tests.js | @@ -18,7 +18,6 @@ import {
zero3,
one3
} from './Constants.tests';
-import { Cache } from '../../../../build/three';
function comparePlane( a, b, threshold ) {
| false |
Other | mrdoob | three.js | 97951a622ae7931728775f6fc5f9c29c2bf5b89c.json | add Plane unittests | src/math/Plane.js | @@ -16,6 +16,8 @@ function Plane( normal, constant ) {
Object.assign( Plane.prototype, {
+ isPlane: true,
+
set: function ( normal, constant ) {
this.normal.copy( normal ); | true |
Other | mrdoob | three.js | 97951a622ae7931728775f6fc5f9c29c2bf5b89c.json | add Plane unittests | test/unit/src/math/Plane.tests.js | @@ -8,6 +8,7 @@ import { Plane } from '../../../../src/math/Plane';
import { Vector3 } from '../../../../src/math/Vector3';
import { Line3 } from '../../../../src/math/Line3';
import { Sphere } from '../../../../src/math/Sphere';
+import { Box3 } from '../../../../src/math/Box3';
import { Matrix4 } from '../../../../src/math/Matrix4';
import {
x,
@@ -17,6 +18,7 @@ import {
zero3,
one3
} from './Constants.tests';
+import { Cache } from '../../../../build/three';
function comparePlane( a, b, threshold ) {
@@ -54,9 +56,14 @@ export default QUnit.module( 'Maths', () => {
} );
// PUBLIC STUFF
- QUnit.todo( "isPlane", ( assert ) => {
+ QUnit.test( "isPlane", ( assert ) => {
+
+ var a = new Plane();
+ assert.ok( a.isPlane === true, "Passed!" );
+
+ var b = new Vector3();
+ assert.ok( ! b.isPlane, "Passed!" );
- assert.ok( false, "everything's gonna be alright" );
} );
@@ -118,9 +125,13 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "clone", ( assert ) => {
+ QUnit.test( "clone", ( assert ) => {
+
+ var a = new Plane( 2.0, 0.5, 0.25 );
+ var b = a.clone();
+
+ assert.ok( a.equals( b ), "clones are equal" );
- assert.ok( false, "everything's gonna be alright" );
} );
@@ -229,15 +240,41 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "intersectsBox", ( assert ) => {
-
- assert.ok( false, "everything's gonna be alright" );
+ QUnit.test( "intersectsBox", ( assert ) => {
+
+ var a = new Box3( zero3.clone(), one3.clone() );
+ var b = new Plane( new Vector3( 0, 1, 0 ), 1 );
+ var c = new Plane( new Vector3( 0, 1, 0 ), 1.25 );
+ var d = new Plane( new Vector3( 0, - 1, 0 ), 1.25 );
+ var e = new Plane( new Vector3( 0, 1, 0 ), 0.25 );
+ var f = new Plane( new Vector3( 0, 1, 0 ), - 0.25 );
+ var g = new Plane( new Vector3( 0, 1, 0 ), - 0.75 );
+ var h = new Plane( new Vector3( 0, 1, 0 ), - 1 );
+ var i = new Plane( new Vector3( 1, 1, 1 ).normalize(), - 1.732 );
+ var j = new Plane( new Vector3( 1, 1, 1 ).normalize(), - 1.733 );
+
+ assert.ok( ! b.intersectsBox( a ), "Passed!" );
+ assert.ok( ! c.intersectsBox( a ), "Passed!" );
+ assert.ok( ! d.intersectsBox( a ), "Passed!" );
+ assert.ok( ! e.intersectsBox( a ), "Passed!" );
+ assert.ok( f.intersectsBox( a ), "Passed!" );
+ assert.ok( g.intersectsBox( a ), "Passed!" );
+ assert.ok( h.intersectsBox( a ), "Passed!" );
+ assert.ok( i.intersectsBox( a ), "Passed!" );
+ assert.ok( ! j.intersectsBox( a ), "Passed!" );
} );
- QUnit.todo( "intersectsSphere", ( assert ) => {
+ QUnit.test( "intersectsSphere", ( assert ) => {
+
+ var a = new Sphere( zero3.clone(), 1 );
+ var b = new Plane( new Vector3( 0, 1, 0 ), 1 );
+ var c = new Plane( new Vector3( 0, 1, 0 ), 1.25 );
+ var d = new Plane( new Vector3( 0, - 1, 0 ), 1.25 );
- assert.ok( false, "everything's gonna be alright" );
+ assert.ok( b.intersectsSphere( a ), "Passed!" );
+ assert.ok( ! c.intersectsSphere( a ), "Passed!" );
+ assert.ok( ! d.intersectsSphere( a ), "Passed!" );
} );
| true |
Other | mrdoob | three.js | 66d03802f93a6fd98ee855b4b332cbde19b27080.json | remove the link | docs/api/en/extras/ShapeUtils.html | @@ -22,7 +22,7 @@ <h2>Methods</h2>
<h3>[method:Number area]( contour )</h3>
<p>
- contour -- 2D polygon. An array of THREE.Vector2(), according to the <a href="https://github.com/mrdoob/three.js/blob/master/src/extras/ShapeUtils.js#L18">definition</a> of the method.<br /><br />
+ contour -- 2D polygon. An array of THREE.Vector2(), according to the definition of this method.<br /><br />
Calculate area of a ( 2D ) contour polygon.<br /><br />
| false |
Other | mrdoob | three.js | d6907618cd3e4ca8963dfd526f445ddede17026a.json | Catch xr.supportsSession() rejection | examples/js/vr/WebVR.js | @@ -136,7 +136,7 @@ var WEBVR = {
stylizeElement( button );
- navigator.xr.supportsSession( 'immersive-vr' ).then( showEnterXR );
+ navigator.xr.supportsSession( 'immersive-vr' ).then( showEnterXR ).catch( showVRNotFound );
return button;
| false |
Other | mrdoob | three.js | 66c410a543e13581a56053e0a055be68f89ccf07.json | Explain the 2D contour
state the format of a contour as a arument | docs/api/en/extras/ShapeUtils.html | @@ -22,7 +22,7 @@ <h2>Methods</h2>
<h3>[method:Number area]( contour )</h3>
<p>
- contour -- 2D polygon.<br /><br />
+ contour -- 2D polygon. An array of THREE.Vector2(), according to the <a href="https://github.com/mrdoob/three.js/blob/master/src/extras/ShapeUtils.js#L18">definition</a> of the method.<br /><br />
Calculate area of a ( 2D ) contour polygon.<br /><br />
| false |
Other | mrdoob | three.js | 9848016d19d1f255ff444bd94f5411e9bcba3603.json | Implement STEP directive | examples/js/loaders/LDrawLoader.js | @@ -684,6 +684,9 @@ THREE.LDrawLoader = ( function () {
triangles: null,
lineSegments: null,
conditionalSegments: null,
+
+ // If true, this object is the start of a construction step
+ startingConstructionStep: false
};
this.parseScopesStack.push( newParseScope );
@@ -1042,6 +1045,8 @@ THREE.LDrawLoader = ( function () {
// Retrieve data from the parent parse scope
var parentParseScope = this.getParentParseScope();
+ var isRoot = ! parentParseScope.isFromParse;
+
// Main colour codes passed to this subobject (or default codes 16 and 24 if it is the root object)
var mainColourCode = parentParseScope.mainColourCode;
var mainEdgeColourCode = parentParseScope.mainEdgeColourCode;
@@ -1079,6 +1084,8 @@ THREE.LDrawLoader = ( function () {
var bfcCull = true;
var type = '';
+ var startingConstructionStep = false;
+
var scope = this;
function parseColourCode( lineParser, forEdge ) {
@@ -1193,6 +1200,8 @@ THREE.LDrawLoader = ( function () {
currentParseScope.groupObject = new THREE.Group();
+ currentParseScope.groupObject.userData.startingConstructionStep = currentParseScope.startingConstructionStep;
+
}
// If the scale of the object is negated then the triangle winding order
@@ -1320,6 +1329,12 @@ THREE.LDrawLoader = ( function () {
break;
+ case 'STEP':
+
+ startingConstructionStep = true;
+
+ break;
+
default:
// Other meta directives are not implemented
break;
@@ -1385,7 +1400,8 @@ THREE.LDrawLoader = ( function () {
locationState: LDrawLoader.FILE_LOCATION_AS_IS,
url: null,
triedLowerCase: false,
- inverted: bfcInverted !== currentParseScope.inverted
+ inverted: bfcInverted !== currentParseScope.inverted,
+ startingConstructionStep: startingConstructionStep
} );
bfcInverted = false;
@@ -1594,6 +1610,32 @@ THREE.LDrawLoader = ( function () {
},
+ computeConstructionSteps: function ( model ) {
+
+ // Sets userdata.constructionStep number in Group objects and userData.numConstructionSteps number in the root Group object.
+
+ var stepNumber = 0;
+
+ model.traverse( c => {
+
+ if ( c.isGroup ) {
+
+ if ( c.userData.startingConstructionStep ) {
+
+ stepNumber ++;
+
+ }
+
+ c.userData.constructionStep = stepNumber;
+
+ }
+
+ } );
+
+ model.userData.numConstructionSteps = stepNumber + 1;
+
+ },
+
processObject: function ( text, onProcessed, subobject, url ) {
var scope = this;
@@ -1609,6 +1651,7 @@ THREE.LDrawLoader = ( function () {
parseScope.currentMatrix.multiplyMatrices( parentParseScope.currentMatrix, subobject.matrix );
parseScope.matrix.copy( subobject.matrix );
parseScope.inverted = subobject.inverted;
+ parseScope.startingConstructionStep = subobject.startingConstructionStep;
}
@@ -1763,6 +1806,13 @@ THREE.LDrawLoader = ( function () {
scope.removeScopeLevel();
+ // If it is root object, compute construction steps
+ if ( ! parentParseScope.isFromParse ) {
+
+ scope.computeConstructionSteps( parseScope.groupObject );
+
+ }
+
if ( onProcessed ) {
onProcessed( parseScope.groupObject ); | true |
Other | mrdoob | three.js | 9848016d19d1f255ff444bd94f5411e9bcba3603.json | Implement STEP directive | examples/jsm/loaders/LDrawLoader.js | @@ -702,6 +702,9 @@ var LDrawLoader = ( function () {
triangles: null,
lineSegments: null,
conditionalSegments: null,
+
+ // If true, this object is the start of a construction step
+ startingConstructionStep: false
};
this.parseScopesStack.push( newParseScope );
@@ -1060,6 +1063,8 @@ var LDrawLoader = ( function () {
// Retrieve data from the parent parse scope
var parentParseScope = this.getParentParseScope();
+ var isRoot = ! parentParseScope.isFromParse;
+
// Main colour codes passed to this subobject (or default codes 16 and 24 if it is the root object)
var mainColourCode = parentParseScope.mainColourCode;
var mainEdgeColourCode = parentParseScope.mainEdgeColourCode;
@@ -1097,6 +1102,8 @@ var LDrawLoader = ( function () {
var bfcCull = true;
var type = '';
+ var startingConstructionStep = false;
+
var scope = this;
function parseColourCode( lineParser, forEdge ) {
@@ -1211,6 +1218,8 @@ var LDrawLoader = ( function () {
currentParseScope.groupObject = new Group();
+ currentParseScope.groupObject.userData.startingConstructionStep = currentParseScope.startingConstructionStep;
+
}
// If the scale of the object is negated then the triangle winding order
@@ -1338,6 +1347,12 @@ var LDrawLoader = ( function () {
break;
+ case 'STEP':
+
+ startingConstructionStep = true;
+
+ break;
+
default:
// Other meta directives are not implemented
break;
@@ -1403,7 +1418,8 @@ var LDrawLoader = ( function () {
locationState: LDrawLoader.FILE_LOCATION_AS_IS,
url: null,
triedLowerCase: false,
- inverted: bfcInverted !== currentParseScope.inverted
+ inverted: bfcInverted !== currentParseScope.inverted,
+ startingConstructionStep: startingConstructionStep
} );
bfcInverted = false;
@@ -1612,6 +1628,32 @@ var LDrawLoader = ( function () {
},
+ computeConstructionSteps: function ( model ) {
+
+ // Sets userdata.constructionStep number in Group objects and userData.numConstructionSteps number in the root Group object.
+
+ var stepNumber = 0;
+
+ model.traverse( c => {
+
+ if ( c.isGroup ) {
+
+ if ( c.userData.startingConstructionStep ) {
+
+ stepNumber ++;
+
+ }
+
+ c.userData.constructionStep = stepNumber;
+
+ }
+
+ } );
+
+ model.userData.numConstructionSteps = stepNumber + 1;
+
+ },
+
processObject: function ( text, onProcessed, subobject, url ) {
var scope = this;
@@ -1627,6 +1669,7 @@ var LDrawLoader = ( function () {
parseScope.currentMatrix.multiplyMatrices( parentParseScope.currentMatrix, subobject.matrix );
parseScope.matrix.copy( subobject.matrix );
parseScope.inverted = subobject.inverted;
+ parseScope.startingConstructionStep = subobject.startingConstructionStep;
}
@@ -1781,6 +1824,13 @@ var LDrawLoader = ( function () {
scope.removeScopeLevel();
+ // If it is root object, compute construction steps
+ if ( ! parentParseScope.isFromParse ) {
+
+ scope.computeConstructionSteps( parseScope.groupObject );
+
+ }
+
if ( onProcessed ) {
onProcessed( parseScope.groupObject ); | true |
Other | mrdoob | three.js | 9848016d19d1f255ff444bd94f5411e9bcba3603.json | Implement STEP directive | examples/webgl_loader_ldraw.html | @@ -110,48 +110,11 @@
separateObjects: false,
displayLines: true,
conditionalLines: true,
- smoothNormals: true
+ smoothNormals: true,
+ constructionStep: 0,
+ noConstructionSteps: "No steps."
};
- gui = new GUI();
-
- gui.add( guiData, 'modelFileName', modelFileList ).name( 'Model' ).onFinishChange( function () {
-
- reloadObject( true );
-
- } );
-
- gui.add( guiData, 'envMapActivated' ).name( 'Env. map' ).onChange( function ( value ) {
-
- envMapActivated = value;
-
- reloadObject( false );
-
- } );
-
- gui.add( guiData, 'separateObjects' ).name( 'Separate Objects' ).onChange( function () {
-
- reloadObject( false );
-
- } );
-
- gui.add( guiData, 'smoothNormals' ).name( 'Smooth Normals' ).onChange( function () {
-
- reloadObject( false );
-
- } );
-
- gui.add( guiData, 'displayLines' ).name( 'Display Lines' ).onChange( function () {
-
- updateLineSegments();
-
- } );
-
- gui.add( guiData, 'conditionalLines' ).name( 'Conditional Lines' ).onChange( function () {
-
- updateLineSegments();
-
- } );
window.addEventListener( 'resize', onWindowResize, false );
progressBarDiv = document.createElement( 'div' );
@@ -171,7 +134,7 @@
}
- function updateLineSegments() {
+ function updateObjectsVisibility() {
model.traverse( c => {
@@ -188,6 +151,12 @@
}
}
+ else if ( c.isGroup ) {
+
+ // Hide objects with construction step > gui setting
+ c.visible = c.userData.constructionStep <= guiData.constructionStep;
+
+ }
} );
@@ -259,7 +228,9 @@
}
- updateLineSegments();
+ guiData.constructionStep = model.userData.numConstructionSteps - 1;
+
+ updateObjectsVisibility();
// Adjust camera and light
@@ -275,6 +246,8 @@
}
+ createGUI();
+
hideProgressBar();
}, onProgress, onError );
@@ -290,6 +263,59 @@
}
+ function createGUI() {
+
+ if ( gui ) {
+
+ gui.destroy();
+ }
+
+ gui = new GUI();
+
+ gui.add( guiData, 'modelFileName', modelFileList ).name( 'Model' ).onFinishChange( function () {
+
+ reloadObject( true );
+
+ } );
+
+ gui.add( guiData, 'separateObjects' ).name( 'Separate Objects' ).onChange( function ( value ) {
+
+ reloadObject( false );
+
+ } );
+
+ if ( guiData.separateObjects ) {
+
+ if ( model.userData.numConstructionSteps > 1 ) {
+
+ gui.add( guiData, 'constructionStep', 0, model.userData.numConstructionSteps - 1 ).step( 1 ).name( 'Construction step' ).onChange( updateObjectsVisibility );
+
+ }
+ else {
+
+ gui.add( guiData, 'noConstructionSteps' ).name( 'Construction step' ).onChange( updateObjectsVisibility );
+
+ }
+ }
+
+ gui.add( guiData, 'envMapActivated' ).name( 'Env. map' ).onChange( function changeEnvMap ( value ) {
+
+ envMapActivated = value;
+ reloadObject( false );
+
+ } );
+
+ gui.add( guiData, 'smoothNormals' ).name( 'Smooth Normals' ).onChange( function changeNormals ( value ) {
+
+ reloadObject( false );
+
+ } );
+
+ gui.add( guiData, 'displayLines' ).name( 'Display Lines' ).onChange( updateObjectsVisibility );
+ gui.add( guiData, 'conditionalLines' ).name( 'Conditional Lines' ).onChange( updateObjectsVisibility );
+
+ }
+
//
function animate() { | true |
Other | mrdoob | three.js | f0151321810eac88a04ec2509dde6a3a72869350.json | add Matrix4 unittests | test/unit/src/math/Matrix4.tests.js | @@ -79,9 +79,13 @@ export default QUnit.module( 'Maths', () => {
} );
// PUBLIC STUFF
- QUnit.todo( "isMatrix4", ( assert ) => {
+ QUnit.test( "isMatrix4", ( assert ) => {
- assert.ok( false, "everything's gonna be alright" );
+ var a = new Matrix4();
+ assert.ok( a.isMatrix4 === true, "Passed!" );
+
+ var b = new Vector3();
+ assert.ok( ! b.isMatrix4, "Passed!" );
} );
@@ -215,12 +219,6 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "extractRotation", ( assert ) => {
-
- assert.ok( false, "everything's gonna be alright" );
-
- } );
-
QUnit.test( "makeRotationFromEuler/extractRotation", ( assert ) => {
var testValues = [
@@ -284,15 +282,56 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "multiply", ( assert ) => {
+ QUnit.test( "multiply", ( assert ) => {
+
+ var lhs = new Matrix4().set( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 );
+ var rhs = new Matrix4().set( 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131 );
+
+ lhs.multiply( rhs );
- assert.ok( false, "everything's gonna be alright" );
+ assert.ok( lhs.elements[ 0 ] == 1585 );
+ assert.ok( lhs.elements[ 1 ] == 5318 );
+ assert.ok( lhs.elements[ 2 ] == 10514 );
+ assert.ok( lhs.elements[ 3 ] == 15894 );
+ assert.ok( lhs.elements[ 4 ] == 1655 );
+ assert.ok( lhs.elements[ 5 ] == 5562 );
+ assert.ok( lhs.elements[ 6 ] == 11006 );
+ assert.ok( lhs.elements[ 7 ] == 16634 );
+ assert.ok( lhs.elements[ 8 ] == 1787 );
+ assert.ok( lhs.elements[ 9 ] == 5980 );
+ assert.ok( lhs.elements[ 10 ] == 11840 );
+ assert.ok( lhs.elements[ 11 ] == 17888 );
+ assert.ok( lhs.elements[ 12 ] == 1861 );
+ assert.ok( lhs.elements[ 13 ] == 6246 );
+ assert.ok( lhs.elements[ 14 ] == 12378 );
+ assert.ok( lhs.elements[ 15 ] == 18710 );
} );
- QUnit.todo( "premultiply", ( assert ) => {
+ QUnit.test( "premultiply", ( assert ) => {
+
+ var lhs = new Matrix4().set( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 );
+ var rhs = new Matrix4().set( 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131 );
+
+ rhs.premultiply( lhs );
+
+ assert.ok( rhs.elements[ 0 ] == 1585 );
+ assert.ok( rhs.elements[ 1 ] == 5318 );
+ assert.ok( rhs.elements[ 2 ] == 10514 );
+ assert.ok( rhs.elements[ 3 ] == 15894 );
+ assert.ok( rhs.elements[ 4 ] == 1655 );
+ assert.ok( rhs.elements[ 5 ] == 5562 );
+ assert.ok( rhs.elements[ 6 ] == 11006 );
+ assert.ok( rhs.elements[ 7 ] == 16634 );
+ assert.ok( rhs.elements[ 8 ] == 1787 );
+ assert.ok( rhs.elements[ 9 ] == 5980 );
+ assert.ok( rhs.elements[ 10 ] == 11840 );
+ assert.ok( rhs.elements[ 11 ] == 17888 );
+ assert.ok( rhs.elements[ 12 ] == 1861 );
+ assert.ok( rhs.elements[ 13 ] == 6246 );
+ assert.ok( rhs.elements[ 14 ] == 12378 );
+ assert.ok( rhs.elements[ 15 ] == 18710 );
- assert.ok( false, "everything's gonna be alright" );
} );
@@ -433,9 +472,14 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "setPosition", ( assert ) => {
+ QUnit.test( "setPosition", ( assert ) => {
- assert.ok( false, "everything's gonna be alright" );
+ var a = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
+ var b = new Vector3( - 1, - 2, - 3 );
+ var c = new Matrix4().set( 0, 1, 2, - 1, 4, 5, 6, - 2, 8, 9, 10, - 3, 12, 13, 14, 15 );
+
+ a.setPosition( b );
+ assert.ok( matrixEquals4( a, c ), "Passed!" );
} );
@@ -500,9 +544,14 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "scale", ( assert ) => {
+ QUnit.test( "scale", ( assert ) => {
- assert.ok( false, "everything's gonna be alright" );
+ var a = new Matrix4().set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
+ var b = new Vector3( 2, 3, 4 );
+ var c = new Matrix4().set( 2, 6, 12, 4, 10, 18, 28, 8, 18, 30, 44, 12, 26, 42, 60, 16 );
+
+ a.scale( b );
+ assert.ok( matrixEquals4( a, c ), "Passed!" );
} );
@@ -515,27 +564,49 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "makeTranslation", ( assert ) => {
+ QUnit.test( "makeTranslation", ( assert ) => {
+
+ var a = new Matrix4();
+ var b = new Vector3( 2, 3, 4 );
+ var c = new Matrix4().set( 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0, 0, 0, 1 );
- assert.ok( false, "everything's gonna be alright" );
+ a.makeTranslation( b );
+ assert.ok( matrixEquals4( a, c ), "Passed!" );
} );
- QUnit.todo( "makeRotationX", ( assert ) => {
+ QUnit.test( "makeRotationX", ( assert ) => {
+
+ var a = new Matrix4();
+ var b = Math.sqrt( 3 ) / 2;
+ var c = new Matrix4().set( 1, 0, 0, 0, 0, b, - 0.5, 0, 0, 0.5, b, 0, 0, 0, 0, 1 );
- assert.ok( false, "everything's gonna be alright" );
+ a.makeRotationX( Math.PI / 6 );
+ assert.ok( matrixEquals4( a, c ), "Passed!" );
} );
- QUnit.todo( "makeRotationY", ( assert ) => {
+ QUnit.test( "makeRotationY", ( assert ) => {
+
+
+ var a = new Matrix4();
+ var b = Math.sqrt( 3 ) / 2;
+ var c = new Matrix4().set( b, 0, 0.5, 0, 0, 1, 0, 0, - 0.5, 0, b, 0, 0, 0, 0, 1 );
- assert.ok( false, "everything's gonna be alright" );
+ a.makeRotationY( Math.PI / 6 );
+ assert.ok( matrixEquals4( a, c ), "Passed!" );
} );
- QUnit.todo( "makeRotationZ", ( assert ) => {
+ QUnit.test( "makeRotationZ", ( assert ) => {
+
- assert.ok( false, "everything's gonna be alright" );
+ var a = new Matrix4();
+ var b = Math.sqrt( 3 ) / 2;
+ var c = new Matrix4().set( b, - 0.5, 0, 0, 0.5, b, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 );
+
+ a.makeRotationZ( Math.PI / 6 );
+ assert.ok( matrixEquals4( a, c ), "Passed!" );
} );
@@ -556,15 +627,23 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "makeScale", ( assert ) => {
+ QUnit.test( "makeScale", ( assert ) => {
+
+ var a = new Matrix4();
+ var c = new Matrix4().set( 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1 );
- assert.ok( false, "everything's gonna be alright" );
+ a.makeScale( 2, 3, 4 );
+ assert.ok( matrixEquals4( a, c ), "Passed!" );
} );
- QUnit.todo( "makeShear", ( assert ) => {
+ QUnit.test( "makeShear", ( assert ) => {
+
+ var a = new Matrix4();
+ var c = new Matrix4().set( 1, 3, 4, 0, 2, 1, 4, 0, 2, 3, 1, 0, 0, 0, 0, 1 );
- assert.ok( false, "everything's gonna be alright" );
+ a.makeShear( 2, 3, 4 );
+ assert.ok( matrixEquals4( a, c ), "Passed!" );
} );
@@ -642,9 +721,16 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "makePerspective", ( assert ) => {
+ QUnit.test( "makePerspective", ( assert ) => {
- assert.ok( false, "everything's gonna be alright" );
+ var a = new Matrix4().makePerspective( - 1, 1, - 1, 1, 1, 100 );
+ var expected = new Matrix4().set(
+ 1, 0, 0, 0,
+ 0, - 1, 0, 0,
+ 0, 0, - 101 / 99, - 200 / 99,
+ 0, 0, - 1, 0
+ );
+ assert.ok( matrixEquals4( a, expected ), "Check result" );
} );
@@ -676,9 +762,13 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "fromArray", ( assert ) => {
+ QUnit.test( "fromArray", ( assert ) => {
+
+ var a = new Matrix4();
+ var b = new Matrix4().set( 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 );
- assert.ok( false, "everything's gonna be alright" );
+ a.fromArray( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] );
+ assert.ok( a.equals( b ), "Passed" );
} );
| false |
Other | mrdoob | three.js | be422c3767e4b777658d298025f07dd20c0d70f8.json | lint the code | test/unit/src/math/Math.tests.js | @@ -52,9 +52,9 @@ export default QUnit.module( 'Maths', () => {
QUnit.test( "lerp", ( assert ) => {
- assert.strictEqual(ThreeMath.lerp(1, 2, 0), 1, "Value equal to lower boundary");
- assert.strictEqual(ThreeMath.lerp(1, 2, 1), 2, "Value equal to upper boundary");
- assert.strictEqual(ThreeMath.lerp(1, 2, 0.4), 1.4, "Value within range");
+ assert.strictEqual( ThreeMath.lerp( 1, 2, 0 ), 1, "Value equal to lower boundary" );
+ assert.strictEqual( ThreeMath.lerp( 1, 2, 1 ), 2, "Value equal to upper boundary" );
+ assert.strictEqual( ThreeMath.lerp( 1, 2, 0.4 ), 1.4, "Value within range" );
} );
@@ -73,13 +73,13 @@ export default QUnit.module( 'Maths', () => {
QUnit.test( "smootherstep", ( assert ) => {
- assert.strictEqual(ThreeMath.smootherstep(- 1, 0, 2), 0, "Value lower than minimum");
- assert.strictEqual(ThreeMath.smootherstep(0, 0, 2), 0, "Value equal to minimum");
- assert.strictEqual(ThreeMath.smootherstep(0.5, 0, 2), 0.103515625, "Value within limits");
- assert.strictEqual(ThreeMath.smootherstep(1, 0, 2), 0.5, "Value within limits");
- assert.strictEqual(ThreeMath.smootherstep(1.5, 0, 2), 0.896484375, "Value within limits");
- assert.strictEqual(ThreeMath.smootherstep(2, 0, 2), 1, "Value equal to maximum");
- assert.strictEqual(ThreeMath.smootherstep(3, 0, 2), 1, "Value highter than maximum");
+ assert.strictEqual( ThreeMath.smootherstep( - 1, 0, 2 ), 0, "Value lower than minimum" );
+ assert.strictEqual( ThreeMath.smootherstep( 0, 0, 2 ), 0, "Value equal to minimum" );
+ assert.strictEqual( ThreeMath.smootherstep( 0.5, 0, 2 ), 0.103515625, "Value within limits" );
+ assert.strictEqual( ThreeMath.smootherstep( 1, 0, 2 ), 0.5, "Value within limits" );
+ assert.strictEqual( ThreeMath.smootherstep( 1.5, 0, 2 ), 0.896484375, "Value within limits" );
+ assert.strictEqual( ThreeMath.smootherstep( 2, 0, 2 ), 1, "Value equal to maximum" );
+ assert.strictEqual( ThreeMath.smootherstep( 3, 0, 2 ), 1, "Value highter than maximum" );
} );
| false |
Other | mrdoob | three.js | 2eb06eeaaaf68d62aa850f9fd995faf1eff263c5.json | add Matrix3 unit tests | test/unit/src/math/Matrix3.tests.js | @@ -77,9 +77,13 @@ export default QUnit.module( 'Maths', () => {
} );
// PUBLIC STUFF
- QUnit.todo( "isMatrix3", ( assert ) => {
+ QUnit.test( "isMatrix3", ( assert ) => {
- assert.ok( false, "everything's gonna be alright" );
+ var a = new Matrix3();
+ assert.ok( a.isMatrix3 === true, "Passed!" );
+
+ var b = new Matrix4();
+ assert.ok( ! b.isMatrix3, "Passed!" );
} );
@@ -148,9 +152,14 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "setFromMatrix4", ( assert ) => {
+ QUnit.test( "setFromMatrix4", ( assert ) => {
+
- assert.ok( false, "everything's gonna be alright" );
+ var a = new Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
+ var b = new Matrix3();
+ var c = new Matrix3().set( 0, 1, 2, 4, 5, 6, 8, 9, 10 );
+ b.setFromMatrix4( a );
+ assert.ok( b.equals( c ) );
} );
@@ -349,9 +358,22 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "transposeIntoArray", ( assert ) => {
+ QUnit.test( "transposeIntoArray", ( assert ) => {
- assert.ok( false, "everything's gonna be alright" );
+ var a = new Matrix3().set( 0, 1, 2, 3, 4, 5, 6, 7, 8 );
+ var b = [];
+ a.transposeIntoArray( b );
+
+ assert.ok( b[ 0 ] == 0 );
+ assert.ok( b[ 1 ] == 1 );
+ assert.ok( b[ 2 ] == 2 );
+ assert.ok( b[ 3 ] == 3 );
+ assert.ok( b[ 4 ] == 4 );
+ assert.ok( b[ 5 ] == 5 );
+ assert.ok( b[ 5 ] == 5 );
+ assert.ok( b[ 6 ] == 6 );
+ assert.ok( b[ 7 ] == 7 );
+ assert.ok( b[ 8 ] == 8 );
} );
@@ -449,9 +471,33 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "fromArray", ( assert ) => {
+ QUnit.test( "fromArray", ( assert ) => {
+
+ var b = new Matrix3();
+ b.fromArray( [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ] );
+
+ assert.ok( b.elements[ 0 ] == 0 );
+ assert.ok( b.elements[ 1 ] == 1 );
+ assert.ok( b.elements[ 2 ] == 2 );
+ assert.ok( b.elements[ 3 ] == 3 );
+ assert.ok( b.elements[ 4 ] == 4 );
+ assert.ok( b.elements[ 5 ] == 5 );
+ assert.ok( b.elements[ 6 ] == 6 );
+ assert.ok( b.elements[ 7 ] == 7 );
+ assert.ok( b.elements[ 8 ] == 8 );
- assert.ok( false, "everything's gonna be alright" );
+ b = new Matrix3();
+ b.fromArray( [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 ], 10 );
+
+ assert.ok( b.elements[ 0 ] == 10 );
+ assert.ok( b.elements[ 1 ] == 11 );
+ assert.ok( b.elements[ 2 ] == 12 );
+ assert.ok( b.elements[ 3 ] == 13 );
+ assert.ok( b.elements[ 4 ] == 14 );
+ assert.ok( b.elements[ 5 ] == 15 );
+ assert.ok( b.elements[ 6 ] == 16 );
+ assert.ok( b.elements[ 7 ] == 17 );
+ assert.ok( b.elements[ 8 ] == 18 );
} );
| false |
Other | mrdoob | three.js | 5a026e572824f86e932e8a6af665d5c34fd0712d.json | Add math unittests | test/unit/src/math/Math.tests.js | @@ -49,9 +49,13 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "lerp", ( assert ) => {
+ QUnit.test( "lerp", ( assert ) => {
+
+
+ assert.strictEqual(ThreeMath.lerp(1, 2, 0), 1, "Value equal to lower boundary");
+ assert.strictEqual(ThreeMath.lerp(1, 2, 1), 2, "Value equal to upper boundary");
+ assert.strictEqual(ThreeMath.lerp(1, 2, 0.4), 1.4, "Value within range");
- assert.ok( false, "everything's gonna be alright" );
} );
@@ -67,9 +71,15 @@ export default QUnit.module( 'Maths', () => {
} );
- QUnit.todo( "smootherstep", ( assert ) => {
+ QUnit.test( "smootherstep", ( assert ) => {
- assert.ok( false, "everything's gonna be alright" );
+ assert.strictEqual(ThreeMath.smootherstep(- 1, 0, 2), 0, "Value lower than minimum");
+ assert.strictEqual(ThreeMath.smootherstep(0, 0, 2), 0, "Value equal to minimum");
+ assert.strictEqual(ThreeMath.smootherstep(0.5, 0, 2), 0.103515625, "Value within limits");
+ assert.strictEqual(ThreeMath.smootherstep(1, 0, 2), 0.5, "Value within limits");
+ assert.strictEqual(ThreeMath.smootherstep(1.5, 0, 2), 0.896484375, "Value within limits");
+ assert.strictEqual(ThreeMath.smootherstep(2, 0, 2), 1, "Value equal to maximum");
+ assert.strictEqual(ThreeMath.smootherstep(3, 0, 2), 1, "Value highter than maximum");
} );
| false |
Other | mrdoob | three.js | 654fb5ed564429027d960494d1b1045a2351b436.json | update sea3d examples to modules | examples/webgl_loader_sea3d.html | @@ -13,35 +13,34 @@
Geometry Compression with <a href="https://github.com/google/draco" target="_blank" rel="noopener">Google Draco</a> and content with LZMA using <a href="http://sunag.github.io/sea3d/IO/index.html" style="color:#FFFFFF" target="_blank">SEA3D I.O.</a> Tools<br>
</div>
- <script src="../build/three.js"></script>
-
- <script src="js/controls/OrbitControls.js"></script>
-
- <script src="js/postprocessing/EffectComposer.js"></script>
- <script src="js/postprocessing/RenderPass.js"></script>
- <script src="js/postprocessing/ShaderPass.js"></script>
- <script src="js/postprocessing/MaskPass.js"></script>
- <script src="js/shaders/CopyShader.js"></script>
- <script src="js/shaders/ColorCorrectionShader.js"></script>
- <script src="js/shaders/VignetteShader.js"></script>
-
- <script src="js/loaders/sea3d/SEA3D.js"></script>
- <script src="js/loaders/sea3d/SEA3DLZMA.js"></script>
- <script src="js/loaders/sea3d/SEA3DLoader.js"></script>
-
<script src="js/libs/draco/draco_decoder.js"></script>
- <script src="js/loaders/sea3d/SEA3DDraco.js"></script>
- <script src="js/WebGL.js"></script>
- <script src="js/libs/stats.min.js"></script>
+ <script type="module">
- <script>
+ import {
+ Vector3,
+ Color,
+ Clock,
+ PerspectiveCamera,
+ Scene,
+ WebGLRenderer
+ } from "../build/three.module.js";
- if ( WEBGL.isWebGLAvailable() === false ) {
+ import { OrbitControls } from './jsm/controls/OrbitControls.js';
- document.body.appendChild( WEBGL.getWebGLErrorMessage() );
+ import { EffectComposer } from './jsm/postprocessing/EffectComposer.js';
+ import { RenderPass } from './jsm/postprocessing/RenderPass.js';
+ import { ShaderPass } from './jsm/postprocessing/ShaderPass.js';
+ import { MaskPass } from './jsm/postprocessing/MaskPass.js';
+ import { CopyShader } from './jsm/shaders/CopyShader.js';
+ import { ColorCorrectionShader } from './jsm/shaders/ColorCorrectionShader.js';
+ import { VignetteShader } from './jsm/shaders/VignetteShader.js';
- }
+ import { SEA3D } from './jsm/loaders/sea3d/SEA3DLoader.js';
+ import './jsm/loaders/sea3d/SEA3DLZMA.js'; // sea3d lzma extension
+ import './jsm/loaders/sea3d/SEA3DDraco.js'; // sea3d draco extension
+
+ import Stats from './jsm/libs/stats.module.js';
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
@@ -59,7 +58,7 @@
// SEA3D Loader
//
- loader = new THREE.SEA3D( {
+ loader = new SEA3D( {
autoPlay: true, // Auto play animations
container: scene, // Container to add models
@@ -86,42 +85,42 @@
function init() {
- scene = new THREE.Scene();
- scene.background = new THREE.Color( 0x333333 );
+ scene = new Scene();
+ scene.background = new Color( 0x333333 );
container = document.createElement( 'div' );
document.body.appendChild( container );
- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
+ camera = new PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.set( 1000, 1000, 1000 );
camera.lookAt( 0, 0, 0 );
- renderer = new THREE.WebGLRenderer();
+ renderer = new WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
- controls = new THREE.OrbitControls( camera, renderer.domElement );
+ controls = new OrbitControls( camera, renderer.domElement );
stats = new Stats();
container.appendChild( stats.dom );
// post-processing
- composer = new THREE.EffectComposer( renderer );
+ composer = new EffectComposer( renderer );
- var renderPass = new THREE.RenderPass( scene, camera );
- var copyPass = new THREE.ShaderPass( THREE.CopyShader );
+ var renderPass = new RenderPass( scene, camera );
+ var copyPass = new ShaderPass( CopyShader );
composer.addPass( renderPass );
var vh = 1.4, vl = 1.2;
- var colorCorrectionPass = new THREE.ShaderPass( THREE.ColorCorrectionShader );
- colorCorrectionPass.uniforms[ "powRGB" ].value = new THREE.Vector3( vh, vh, vh );
- colorCorrectionPass.uniforms[ "mulRGB" ].value = new THREE.Vector3( vl, vl, vl );
+ var colorCorrectionPass = new ShaderPass( ColorCorrectionShader );
+ colorCorrectionPass.uniforms[ "powRGB" ].value = new Vector3( vh, vh, vh );
+ colorCorrectionPass.uniforms[ "mulRGB" ].value = new Vector3( vl, vl, vl );
composer.addPass( colorCorrectionPass );
- var vignettePass = new THREE.ShaderPass( THREE.VignetteShader );
+ var vignettePass = new ShaderPass( VignetteShader );
vignettePass.uniforms[ "darkness" ].value = 1.0;
composer.addPass( vignettePass );
@@ -146,7 +145,7 @@
//
- var clock = new THREE.Clock();
+ var clock = new Clock();
function animate() {
@@ -155,7 +154,7 @@
requestAnimationFrame( animate );
// Update SEA3D Animations
- THREE.SEA3D.AnimationHandler.update( delta );
+ SEA3D.AnimationHandler.update( delta );
render( delta );
| true |
Other | mrdoob | three.js | 654fb5ed564429027d960494d1b1045a2351b436.json | update sea3d examples to modules | examples/webgl_loader_sea3d_bvh.html | @@ -12,35 +12,42 @@
Runtime convertion of BVH Animation to SEA3D Skeleton Animation
</div>
- <script src="../build/three.js"></script>
-
- <script src="js/controls/OrbitControls.js"></script>
-
- <script src="js/postprocessing/EffectComposer.js"></script>
- <script src="js/postprocessing/RenderPass.js"></script>
- <script src="js/postprocessing/ShaderPass.js"></script>
- <script src="js/postprocessing/MaskPass.js"></script>
- <script src="js/shaders/CopyShader.js"></script>
- <script src="js/shaders/ColorCorrectionShader.js"></script>
- <script src="js/shaders/VignetteShader.js"></script>
-
- <script src="js/loaders/sea3d/SEA3D.js"></script>
- <script src="js/loaders/sea3d/SEA3DLZMA.js"></script>
- <script src="js/loaders/sea3d/SEA3DLoader.js"></script>
-
- <script src="js/loaders/BVHLoader.js"></script>
- <script src="js/utils/SkeletonUtils.js"></script>
-
- <script src="js/WebGL.js"></script>
- <script src="js/libs/stats.min.js"></script>
-
- <script>
-
- if ( WEBGL.isWebGLAvailable() === false ) {
-
- document.body.appendChild( WEBGL.getWebGLErrorMessage() );
-
- }
+ <script type="module">
+
+ import {
+ Vector3,
+ Color,
+ Matrix4,
+ Euler,
+ Math,
+ Clock,
+ Group,
+ Object3D,
+ AnimationMixer,
+ SkeletonHelper,
+ PerspectiveCamera,
+ Scene,
+ WebGLRenderer
+ } from "../build/three.module.js";
+
+ import { OrbitControls } from './jsm/controls/OrbitControls.js';
+
+ import { EffectComposer } from './jsm/postprocessing/EffectComposer.js';
+ import { RenderPass } from './jsm/postprocessing/RenderPass.js';
+ import { ShaderPass } from './jsm/postprocessing/ShaderPass.js';
+ import { MaskPass } from './jsm/postprocessing/MaskPass.js';
+ import { CopyShader } from './jsm/shaders/CopyShader.js';
+ import { ColorCorrectionShader } from './jsm/shaders/ColorCorrectionShader.js';
+ import { VignetteShader } from './jsm/shaders/VignetteShader.js';
+
+ import { BVHLoader } from './jsm/loaders/BVHLoader.js';
+
+ import { SEA3D } from './jsm/loaders/sea3d/SEA3DLoader.js';
+ import './jsm/loaders/sea3d/SEA3DLZMA.js'; // sea3d lzma extension
+
+ import { SkeletonUtils } from './jsm/utils/SkeletonUtils.js';
+
+ import Stats from './jsm/libs/stats.module.js';
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
@@ -60,7 +67,7 @@
// SEA3D Loader
//
- loader = new THREE.SEA3D( {
+ loader = new SEA3D( {
autoPlay: true, // Auto play animations
container: scene, // Container to add models
@@ -77,7 +84,7 @@
camera.position.copy( cam.position );
camera.rotation.copy( cam.rotation );
- new THREE.OrbitControls( camera, renderer.domElement );
+ new OrbitControls( camera, renderer.domElement );
// get meshes
player = loader.getMesh( "Player" );
@@ -128,49 +135,49 @@
};
// Automatic offset: get offsets when it is in T-Pose
- options.offsets = THREE.SkeletonUtils.getSkeletonOffsets( player, bvhSkeletonHelper, options );
+ options.offsets = SkeletonUtils.getSkeletonOffsets( player, bvhSkeletonHelper, options );
/*
// Manual offsets: compensates the difference in skeletons ( T-Pose )
options.offsets = {
- "lShldr": new THREE.Matrix4().makeRotationFromEuler(
- new THREE.Euler(
+ "lShldr": new Matrix4().makeRotationFromEuler(
+ new Euler(
0,
- THREE.Math.degToRad( - 45 ),
- THREE.Math.degToRad( - 80 )
+ Math.degToRad( - 45 ),
+ Math.degToRad( - 80 )
)
),
- "rShldr": new THREE.Matrix4().makeRotationFromEuler(
- new THREE.Euler(
+ "rShldr": new Matrix4().makeRotationFromEuler(
+ new Euler(
0,
- THREE.Math.degToRad( 45 ),
- THREE.Math.degToRad( 80 )
+ Math.degToRad( 45 ),
+ Math.degToRad( 80 )
)
),
- "lFoot": new THREE.Matrix4().makeRotationFromEuler(
- new THREE.Euler(
+ "lFoot": new Matrix4().makeRotationFromEuler(
+ new Euler(
0,
- THREE.Math.degToRad( 15 ),
+ Math.degToRad( 15 ),
0
)
),
- "rFoot": new THREE.Matrix4().makeRotationFromEuler(
- new THREE.Euler(
+ "rFoot": new Matrix4().makeRotationFromEuler(
+ new Euler(
0,
- THREE.Math.degToRad( 15 ),
+ Math.degToRad( 15 ),
0
)
)
};
*/
- var clip = THREE.SkeletonUtils.retargetClip( player, result.skeleton, result.clip, options );
+ var clip = SkeletonUtils.retargetClip( player, result.skeleton, result.clip, options );
clip.name = "dance";
- clip = THREE.SEA3D.AnimationClip.fromClip( clip );
+ clip = SEA3D.AnimationClip.fromClip( clip );
- player.addAnimation( new THREE.SEA3D.Animation( clip ) );
+ player.addAnimation( new SEA3D.Animation( clip ) );
player.play( "dance" );
@@ -179,21 +186,21 @@
function loadBVH() {
- var loader = new THREE.BVHLoader();
+ var loader = new BVHLoader();
loader.load( "models/bvh/pirouette.bvh", function ( result ) {
- bvhSkeletonHelper = new THREE.SkeletonHelper( result.skeleton.bones[ 0 ] );
+ bvhSkeletonHelper = new SkeletonHelper( result.skeleton.bones[ 0 ] );
bvhSkeletonHelper.skeleton = result.skeleton; // allow animation mixer to bind to SkeletonHelper directly
- var boneContainer = new THREE.Group();
+ var boneContainer = new Group();
boneContainer.add( result.skeleton.bones[ 0 ] );
boneContainer.position.y = - 100;
scene.add( bvhSkeletonHelper );
scene.add( boneContainer );
// play animation
- bvhMixer = new THREE.AnimationMixer( bvhSkeletonHelper );
+ bvhMixer = new AnimationMixer( bvhSkeletonHelper );
bvhMixer.clipAction( result.clip ).setEffectiveWeight( 1.0 ).play();
bvhToSEA3D( result );
@@ -204,16 +211,16 @@
function init() {
- scene = new THREE.Scene();
- scene.background = new THREE.Color( 0x333333 );
+ scene = new Scene();
+ scene.background = new Color( 0x333333 );
container = document.createElement( 'div' );
document.body.appendChild( container );
- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 20000 );
+ camera = new PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 20000 );
camera.position.set( 1000, - 300, 1000 );
- renderer = new THREE.WebGLRenderer();
+ renderer = new WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
@@ -223,20 +230,20 @@
// post-processing
- composer = new THREE.EffectComposer( renderer );
+ composer = new EffectComposer( renderer );
- var renderPass = new THREE.RenderPass( scene, camera );
- var copyPass = new THREE.ShaderPass( THREE.CopyShader );
+ var renderPass = new RenderPass( scene, camera );
+ var copyPass = new ShaderPass( CopyShader );
composer.addPass( renderPass );
var vh = 1.4, vl = 1.2;
- var colorCorrectionPass = new THREE.ShaderPass( THREE.ColorCorrectionShader );
- colorCorrectionPass.uniforms[ "powRGB" ].value = new THREE.Vector3( vh, vh, vh );
- colorCorrectionPass.uniforms[ "mulRGB" ].value = new THREE.Vector3( vl, vl, vl );
+ var colorCorrectionPass = new ShaderPass( ColorCorrectionShader );
+ colorCorrectionPass.uniforms[ "powRGB" ].value = new Vector3( vh, vh, vh );
+ colorCorrectionPass.uniforms[ "mulRGB" ].value = new Vector3( vl, vl, vl );
composer.addPass( colorCorrectionPass );
- var vignettePass = new THREE.ShaderPass( THREE.VignetteShader );
+ var vignettePass = new ShaderPass( VignetteShader );
vignettePass.uniforms[ "darkness" ].value = 1.0;
composer.addPass( vignettePass );
@@ -260,7 +267,7 @@
//
- var clock = new THREE.Clock();
+ var clock = new Clock();
function animate() {
@@ -269,7 +276,7 @@
requestAnimationFrame( animate );
// Update SEA3D Animations
- THREE.SEA3D.AnimationHandler.update( delta );
+ SEA3D.AnimationHandler.update( delta );
if ( bvhMixer ) bvhMixer.update( delta );
| true |
Other | mrdoob | three.js | 654fb5ed564429027d960494d1b1045a2351b436.json | update sea3d examples to modules | examples/webgl_loader_sea3d_bvh_retarget.html | @@ -12,35 +12,39 @@
Runtime retarget of BVH Animation to SEA3D Skeleton
</div>
- <script src="../build/three.js"></script>
+ <script type="module">
- <script src="js/controls/OrbitControls.js"></script>
+ import {
+ Vector3,
+ Color,
+ Clock,
+ Group,
+ Object3D,
+ AnimationMixer,
+ SkeletonHelper,
+ PerspectiveCamera,
+ Scene,
+ WebGLRenderer
+ } from "../build/three.module.js";
- <script src="js/postprocessing/EffectComposer.js"></script>
- <script src="js/postprocessing/RenderPass.js"></script>
- <script src="js/postprocessing/ShaderPass.js"></script>
- <script src="js/postprocessing/MaskPass.js"></script>
- <script src="js/shaders/CopyShader.js"></script>
- <script src="js/shaders/ColorCorrectionShader.js"></script>
- <script src="js/shaders/VignetteShader.js"></script>
+ import { OrbitControls } from './jsm/controls/OrbitControls.js';
- <script src="js/loaders/sea3d/SEA3D.js"></script>
- <script src="js/loaders/sea3d/SEA3DLZMA.js"></script>
- <script src="js/loaders/sea3d/SEA3DLoader.js"></script>
+ import { EffectComposer } from './jsm/postprocessing/EffectComposer.js';
+ import { RenderPass } from './jsm/postprocessing/RenderPass.js';
+ import { ShaderPass } from './jsm/postprocessing/ShaderPass.js';
+ import { MaskPass } from './jsm/postprocessing/MaskPass.js';
+ import { CopyShader } from './jsm/shaders/CopyShader.js';
+ import { ColorCorrectionShader } from './jsm/shaders/ColorCorrectionShader.js';
+ import { VignetteShader } from './jsm/shaders/VignetteShader.js';
- <script src="js/loaders/BVHLoader.js"></script>
- <script src="js/utils/SkeletonUtils.js"></script>
+ import { BVHLoader } from './jsm/loaders/BVHLoader.js';
- <script src="js/WebGL.js"></script>
- <script src="js/libs/stats.min.js"></script>
+ import { SEA3D } from './jsm/loaders/sea3d/SEA3DLoader.js';
+ import './jsm/loaders/sea3d/SEA3DLZMA.js'; // sea3d lzma extension
- <script>
+ import { SkeletonUtils } from './jsm/utils/SkeletonUtils.js';
- if ( WEBGL.isWebGLAvailable() === false ) {
-
- document.body.appendChild( WEBGL.getWebGLErrorMessage() );
-
- }
+ import Stats from './jsm/libs/stats.module.js';
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
@@ -60,7 +64,7 @@
// SEA3D Loader
//
- loader = new THREE.SEA3D( {
+ loader = new SEA3D( {
autoPlay: false, // Auto play animations
container: scene, // Container to add models
@@ -77,7 +81,7 @@
camera.position.copy( cam.position );
camera.rotation.copy( cam.rotation );
- new THREE.OrbitControls( camera, renderer.domElement );
+ new OrbitControls( camera, renderer.domElement );
// get meshes
player = loader.getMesh( "Player" );
@@ -126,13 +130,13 @@
function loadBVH() {
- var loader = new THREE.BVHLoader();
+ var loader = new BVHLoader();
loader.load( "models/bvh/pirouette.bvh", function ( result ) {
- bvhSkeletonHelper = new THREE.SkeletonHelper( result.skeleton.bones[ 0 ] );
+ bvhSkeletonHelper = new SkeletonHelper( result.skeleton.bones[ 0 ] );
bvhSkeletonHelper.skeleton = result.skeleton; // allow animation mixer to bind to SkeletonHelper directly
- var boneContainer = new THREE.Group();
+ var boneContainer = new Group();
boneContainer.add( result.skeleton.bones[ 0 ] );
boneContainer.position.z = - 100;
boneContainer.position.y = - 100;
@@ -141,10 +145,10 @@
scene.add( boneContainer );
// get offsets when it is in T-Pose
- options.offsets = THREE.SkeletonUtils.getSkeletonOffsets( player, bvhSkeletonHelper, options );
+ options.offsets = SkeletonUtils.getSkeletonOffsets( player, bvhSkeletonHelper, options );
// play animation
- bvhMixer = new THREE.AnimationMixer( bvhSkeletonHelper );
+ bvhMixer = new AnimationMixer( bvhSkeletonHelper );
bvhMixer.clipAction( result.clip ).setEffectiveWeight( 1.0 ).play();
} );
@@ -153,16 +157,16 @@
function init() {
- scene = new THREE.Scene();
- scene.background = new THREE.Color( 0x333333 );
+ scene = new Scene();
+ scene.background = new Color( 0x333333 );
container = document.createElement( 'div' );
document.body.appendChild( container );
- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 20000 );
+ camera = new PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 20000 );
camera.position.set( 1000, - 300, 1000 );
- renderer = new THREE.WebGLRenderer();
+ renderer = new WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
@@ -172,20 +176,20 @@
// post-processing
- composer = new THREE.EffectComposer( renderer );
+ composer = new EffectComposer( renderer );
- var renderPass = new THREE.RenderPass( scene, camera );
- var copyPass = new THREE.ShaderPass( THREE.CopyShader );
+ var renderPass = new RenderPass( scene, camera );
+ var copyPass = new ShaderPass( CopyShader );
composer.addPass( renderPass );
var vh = 1.4, vl = 1.2;
- var colorCorrectionPass = new THREE.ShaderPass( THREE.ColorCorrectionShader );
- colorCorrectionPass.uniforms[ "powRGB" ].value = new THREE.Vector3( vh, vh, vh );
- colorCorrectionPass.uniforms[ "mulRGB" ].value = new THREE.Vector3( vl, vl, vl );
+ var colorCorrectionPass = new ShaderPass( ColorCorrectionShader );
+ colorCorrectionPass.uniforms[ "powRGB" ].value = new Vector3( vh, vh, vh );
+ colorCorrectionPass.uniforms[ "mulRGB" ].value = new Vector3( vl, vl, vl );
composer.addPass( colorCorrectionPass );
- var vignettePass = new THREE.ShaderPass( THREE.VignetteShader );
+ var vignettePass = new ShaderPass( VignetteShader );
vignettePass.uniforms[ "darkness" ].value = 1.0;
composer.addPass( vignettePass );
@@ -209,7 +213,7 @@
//
- var clock = new THREE.Clock();
+ var clock = new Clock();
function animate() {
@@ -218,13 +222,13 @@
requestAnimationFrame( animate );
// Update SEA3D Animations
- THREE.SEA3D.AnimationHandler.update( delta );
+ SEA3D.AnimationHandler.update( delta );
if ( bvhMixer ) {
bvhMixer.update( delta );
- THREE.SkeletonUtils.retarget( player, bvhSkeletonHelper, options );
+ SkeletonUtils.retarget( player, bvhSkeletonHelper, options );
}
| true |
Other | mrdoob | three.js | 654fb5ed564429027d960494d1b1045a2351b436.json | update sea3d examples to modules | examples/webgl_loader_sea3d_hierarchy.html | @@ -9,38 +9,35 @@
<body>
<div id="info">
<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - Exported by <a href="https://github.com/sunag/sea3d" target="_blank" rel="noopener">SEA3D Exporter</a> and edited by <a href="https://github.com/sunag/sea3d" target="_blank" rel="noopener">SEA3D Studio</a>.<br/>Asset by <a href="http://vhalldez.cgsociety.org/" target="_blank" rel="noopener">Valdez Araujo</a>.
- High geometry compression with <a href="https://github.com/amd/rest3d/tree/master/server/o3dgc" target="_blank" rel="noopener">Open3DGC</a> and LZMA.
+ Geometry compression lossless with LZMA.
</div>
- <script src="../build/three.js"></script>
+ <script type="module">
- <script src="js/controls/OrbitControls.js"></script>
+ import {
+ Vector3,
+ Color,
+ Clock,
+ PerspectiveCamera,
+ PCFSoftShadowMap,
+ Scene,
+ WebGLRenderer
+ } from "../build/three.module.js";
- <script src="js/postprocessing/EffectComposer.js"></script>
- <script src="js/postprocessing/RenderPass.js"></script>
- <script src="js/postprocessing/ShaderPass.js"></script>
- <script src="js/postprocessing/MaskPass.js"></script>
- <script src="js/shaders/CopyShader.js"></script>
- <script src="js/shaders/ColorCorrectionShader.js"></script>
- <script src="js/shaders/VignetteShader.js"></script>
+ import { OrbitControls } from './jsm/controls/OrbitControls.js';
- <script src="js/loaders/sea3d/SEA3D.js"></script>
- <script src="js/loaders/sea3d/SEA3DLZMA.js"></script>
- <script src="js/loaders/sea3d/SEA3DLoader.js"></script>
+ import { EffectComposer } from './jsm/postprocessing/EffectComposer.js';
+ import { RenderPass } from './jsm/postprocessing/RenderPass.js';
+ import { ShaderPass } from './jsm/postprocessing/ShaderPass.js';
+ import { MaskPass } from './jsm/postprocessing/MaskPass.js';
+ import { CopyShader } from './jsm/shaders/CopyShader.js';
+ import { ColorCorrectionShader } from './jsm/shaders/ColorCorrectionShader.js';
+ import { VignetteShader } from './jsm/shaders/VignetteShader.js';
- <script src="js/libs/o3dgc.js"></script>
- <script src="js/loaders/sea3d/o3dgc/SEA3DGC.js"></script>
+ import { SEA3D } from './jsm/loaders/sea3d/SEA3DLoader.js';
+ import './jsm/loaders/sea3d/SEA3DLZMA.js'; // sea3d lzma extension
- <script src="js/WebGL.js"></script>
- <script src="js/libs/stats.min.js"></script>
-
- <script>
-
- if ( WEBGL.isWebGLAvailable() === false ) {
-
- document.body.appendChild( WEBGL.getWebGLErrorMessage() );
-
- }
+ import Stats from './jsm/libs/stats.module.js';
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
@@ -58,7 +55,7 @@
// SEA3D Loader
//
- loader = new THREE.SEA3D( {
+ loader = new SEA3D( {
autoPlay: false, // Auto play animations
container: scene // Container to add models
@@ -83,7 +80,7 @@
camera.position.copy( cam.position );
camera.rotation.copy( cam.rotation );
- new THREE.OrbitControls( camera, renderer.domElement );
+ new OrbitControls( camera, renderer.domElement );
animate();
@@ -96,43 +93,43 @@
function init() {
- scene = new THREE.Scene();
- scene.background = new THREE.Color( 0x333333 );
+ scene = new Scene();
+ scene.background = new Color( 0x333333 );
container = document.createElement( 'div' );
document.body.appendChild( container );
- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
+ camera = new PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
- renderer = new THREE.WebGLRenderer();
+ renderer = new WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.shadowMap.enabled = true;
- renderer.shadowMap.type = THREE.PCFSoftShadowMap;
+ renderer.shadowMap.type = PCFSoftShadowMap;
container.appendChild( renderer.domElement );
stats = new Stats();
container.appendChild( stats.dom );
// post-processing
- composer = new THREE.EffectComposer( renderer );
+ composer = new EffectComposer( renderer );
- var renderPass = new THREE.RenderPass( scene, camera );
+ var renderPass = new RenderPass( scene, camera );
composer.addPass( renderPass );
var vh = 1.4, vl = 1.2;
- var colorCorrectionPass = new THREE.ShaderPass( THREE.ColorCorrectionShader );
- colorCorrectionPass.uniforms[ "powRGB" ].value = new THREE.Vector3( vh, vh, vh );
- colorCorrectionPass.uniforms[ "mulRGB" ].value = new THREE.Vector3( vl, vl, vl );
+ var colorCorrectionPass = new ShaderPass( ColorCorrectionShader );
+ colorCorrectionPass.uniforms[ "powRGB" ].value = new Vector3( vh, vh, vh );
+ colorCorrectionPass.uniforms[ "mulRGB" ].value = new Vector3( vl, vl, vl );
composer.addPass( colorCorrectionPass );
- var vignettePass = new THREE.ShaderPass( THREE.VignetteShader );
+ var vignettePass = new ShaderPass( VignetteShader );
vignettePass.uniforms[ "darkness" ].value = 1.0;
composer.addPass( vignettePass );
- var copyPass = new THREE.ShaderPass( THREE.CopyShader );
+ var copyPass = new ShaderPass( CopyShader );
composer.addPass( copyPass );
// events
@@ -154,7 +151,7 @@
//
- var clock = new THREE.Clock();
+ var clock = new Clock();
function animate() {
@@ -163,7 +160,7 @@
requestAnimationFrame( animate );
// Update SEA3D Animations
- THREE.SEA3D.AnimationHandler.update( delta );
+ SEA3D.AnimationHandler.update( delta );
render( delta );
| true |
Other | mrdoob | three.js | 654fb5ed564429027d960494d1b1045a2351b436.json | update sea3d examples to modules | examples/webgl_loader_sea3d_keyframe.html | @@ -12,32 +12,31 @@
<div id="description">Click to play</div>
</div>
- <script src="../build/three.js"></script>
+ <script type="module">
- <script src="js/controls/OrbitControls.js"></script>
+ import {
+ Vector3,
+ Color,
+ Clock,
+ PerspectiveCamera,
+ Scene,
+ WebGLRenderer
+ } from "../build/three.module.js";
- <script src="js/postprocessing/EffectComposer.js"></script>
- <script src="js/postprocessing/RenderPass.js"></script>
- <script src="js/postprocessing/ShaderPass.js"></script>
- <script src="js/postprocessing/MaskPass.js"></script>
- <script src="js/shaders/CopyShader.js"></script>
- <script src="js/shaders/ColorCorrectionShader.js"></script>
- <script src="js/shaders/VignetteShader.js"></script>
+ import { OrbitControls } from './jsm/controls/OrbitControls.js';
- <script src="js/loaders/sea3d/SEA3D.js"></script>
- <script src="js/loaders/sea3d/SEA3DLZMA.js"></script>
- <script src="js/loaders/sea3d/SEA3DLoader.js"></script>
+ import { EffectComposer } from './jsm/postprocessing/EffectComposer.js';
+ import { RenderPass } from './jsm/postprocessing/RenderPass.js';
+ import { ShaderPass } from './jsm/postprocessing/ShaderPass.js';
+ import { MaskPass } from './jsm/postprocessing/MaskPass.js';
+ import { CopyShader } from './jsm/shaders/CopyShader.js';
+ import { ColorCorrectionShader } from './jsm/shaders/ColorCorrectionShader.js';
+ import { VignetteShader } from './jsm/shaders/VignetteShader.js';
- <script src="js/WebGL.js"></script>
- <script src="js/libs/stats.min.js"></script>
+ import { SEA3D } from './jsm/loaders/sea3d/SEA3DLoader.js';
+ import './jsm/loaders/sea3d/SEA3DLZMA.js'; // sea3d lzma extension
- <script>
-
- if ( WEBGL.isWebGLAvailable() === false ) {
-
- document.body.appendChild( WEBGL.getWebGLErrorMessage() );
-
- }
+ import Stats from './jsm/libs/stats.module.js';
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
@@ -55,7 +54,7 @@
// SEA3D Loader
//
- loader = new THREE.SEA3D( {
+ loader = new SEA3D( {
autoPlay: false, // Manual play animations
container: scene // Container to add models
@@ -71,7 +70,7 @@
camera.position.copy( cam.position );
camera.rotation.copy( cam.rotation );
- new THREE.OrbitControls( camera, renderer.domElement );
+ new OrbitControls( camera, renderer.domElement );
// events
@@ -126,16 +125,16 @@
function init() {
- scene = new THREE.Scene();
- scene.background = new THREE.Color( 0x333333 );
+ scene = new Scene();
+ scene.background = new Color( 0x333333 );
container = document.createElement( 'div' );
document.body.appendChild( container );
- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
+ camera = new PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.set( 1000, - 300, 1000 );
- renderer = new THREE.WebGLRenderer();
+ renderer = new WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
@@ -145,20 +144,20 @@
// post-processing
- composer = new THREE.EffectComposer( renderer );
+ composer = new EffectComposer( renderer );
- var renderPass = new THREE.RenderPass( scene, camera );
- var copyPass = new THREE.ShaderPass( THREE.CopyShader );
+ var renderPass = new RenderPass( scene, camera );
+ var copyPass = new ShaderPass( CopyShader );
composer.addPass( renderPass );
var vh = 1.4, vl = 1.2;
- var colorCorrectionPass = new THREE.ShaderPass( THREE.ColorCorrectionShader );
- colorCorrectionPass.uniforms[ "powRGB" ].value = new THREE.Vector3( vh, vh, vh );
- colorCorrectionPass.uniforms[ "mulRGB" ].value = new THREE.Vector3( vl, vl, vl );
+ var colorCorrectionPass = new ShaderPass( ColorCorrectionShader );
+ colorCorrectionPass.uniforms[ "powRGB" ].value = new Vector3( vh, vh, vh );
+ colorCorrectionPass.uniforms[ "mulRGB" ].value = new Vector3( vl, vl, vl );
composer.addPass( colorCorrectionPass );
- var vignettePass = new THREE.ShaderPass( THREE.VignetteShader );
+ var vignettePass = new ShaderPass( VignetteShader );
vignettePass.uniforms[ "darkness" ].value = 1.0;
composer.addPass( vignettePass );
@@ -255,7 +254,7 @@
//
- var clock = new THREE.Clock();
+ var clock = new Clock();
function animate() {
@@ -264,7 +263,7 @@
requestAnimationFrame( animate );
// Update SEA3D Animations
- THREE.SEA3D.AnimationHandler.update( delta );
+ SEA3D.AnimationHandler.update( delta );
render( delta );
| true |
Other | mrdoob | three.js | 654fb5ed564429027d960494d1b1045a2351b436.json | update sea3d examples to modules | examples/webgl_loader_sea3d_morph.html | @@ -12,32 +12,31 @@
<div id="description">Flag is Vertex Animation / Teapot is Morpher</div>
</div>
- <script src="../build/three.js"></script>
+ <script type="module">
- <script src="js/controls/OrbitControls.js"></script>
+ import {
+ Vector3,
+ Color,
+ Clock,
+ PerspectiveCamera,
+ Scene,
+ WebGLRenderer
+ } from "../build/three.module.js";
- <script src="js/postprocessing/EffectComposer.js"></script>
- <script src="js/postprocessing/RenderPass.js"></script>
- <script src="js/postprocessing/ShaderPass.js"></script>
- <script src="js/postprocessing/MaskPass.js"></script>
- <script src="js/shaders/CopyShader.js"></script>
- <script src="js/shaders/ColorCorrectionShader.js"></script>
- <script src="js/shaders/VignetteShader.js"></script>
+ import { OrbitControls } from './jsm/controls/OrbitControls.js';
- <script src="js/loaders/sea3d/SEA3D.js"></script>
- <script src="js/loaders/sea3d/SEA3DLZMA.js"></script>
- <script src="js/loaders/sea3d/SEA3DLoader.js"></script>
+ import { EffectComposer } from './jsm/postprocessing/EffectComposer.js';
+ import { RenderPass } from './jsm/postprocessing/RenderPass.js';
+ import { ShaderPass } from './jsm/postprocessing/ShaderPass.js';
+ import { MaskPass } from './jsm/postprocessing/MaskPass.js';
+ import { CopyShader } from './jsm/shaders/CopyShader.js';
+ import { ColorCorrectionShader } from './jsm/shaders/ColorCorrectionShader.js';
+ import { VignetteShader } from './jsm/shaders/VignetteShader.js';
- <script src="js/WebGL.js"></script>
- <script src="js/libs/stats.min.js"></script>
+ import { SEA3D } from './jsm/loaders/sea3d/SEA3DLoader.js';
+ import './jsm/loaders/sea3d/SEA3DLZMA.js'; // sea3d lzma extension
- <script>
-
- if ( WEBGL.isWebGLAvailable() === false ) {
-
- document.body.appendChild( WEBGL.getWebGLErrorMessage() );
-
- }
+ import Stats from './jsm/libs/stats.module.js';
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
@@ -55,7 +54,7 @@
// SEA3D Loader
//
- loader = new THREE.SEA3D( {
+ loader = new SEA3D( {
autoPlay: true, // Auto play animations
scripts: false, // Disable embed scripts
@@ -72,7 +71,7 @@
camera.position.copy( cam.position );
camera.rotation.copy( cam.rotation );
- new THREE.OrbitControls( camera, renderer.domElement );
+ new OrbitControls( camera, renderer.domElement );
// get mesh
@@ -92,16 +91,16 @@
function init() {
- scene = new THREE.Scene();
- scene.background = new THREE.Color( 0x333333 );
+ scene = new Scene();
+ scene.background = new Color( 0x333333 );
container = document.createElement( 'div' );
document.body.appendChild( container );
- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
+ camera = new PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.set( 1000, - 300, 1000 );
- renderer = new THREE.WebGLRenderer();
+ renderer = new WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
@@ -111,20 +110,20 @@
// post-processing
- composer = new THREE.EffectComposer( renderer );
+ composer = new EffectComposer( renderer );
- var renderPass = new THREE.RenderPass( scene, camera );
- var copyPass = new THREE.ShaderPass( THREE.CopyShader );
+ var renderPass = new RenderPass( scene, camera );
+ var copyPass = new ShaderPass( CopyShader );
composer.addPass( renderPass );
var vh = 1.4, vl = 1.2;
- var colorCorrectionPass = new THREE.ShaderPass( THREE.ColorCorrectionShader );
- colorCorrectionPass.uniforms[ "powRGB" ].value = new THREE.Vector3( vh, vh, vh );
- colorCorrectionPass.uniforms[ "mulRGB" ].value = new THREE.Vector3( vl, vl, vl );
+ var colorCorrectionPass = new ShaderPass( ColorCorrectionShader );
+ colorCorrectionPass.uniforms[ "powRGB" ].value = new Vector3( vh, vh, vh );
+ colorCorrectionPass.uniforms[ "mulRGB" ].value = new Vector3( vl, vl, vl );
composer.addPass( colorCorrectionPass );
- var vignettePass = new THREE.ShaderPass( THREE.VignetteShader );
+ var vignettePass = new ShaderPass( VignetteShader );
vignettePass.uniforms[ "darkness" ].value = 1.0;
composer.addPass( vignettePass );
@@ -160,7 +159,7 @@
//
- var clock = new THREE.Clock();
+ var clock = new Clock();
function animate() {
@@ -169,7 +168,7 @@
requestAnimationFrame( animate );
// Update SEA3D Animations
- THREE.SEA3D.AnimationHandler.update( delta );
+ SEA3D.AnimationHandler.update( delta );
render( delta );
| true |
Other | mrdoob | three.js | 654fb5ed564429027d960494d1b1045a2351b436.json | update sea3d examples to modules | examples/webgl_loader_sea3d_physics.html | @@ -13,37 +13,35 @@
<div id="description">Right click to clone</div>
</div>
- <script src="../build/three.js"></script>
-
- <script src="js/controls/OrbitControls.js"></script>
-
- <script src="js/postprocessing/EffectComposer.js"></script>
- <script src="js/postprocessing/RenderPass.js"></script>
- <script src="js/postprocessing/ShaderPass.js"></script>
- <script src="js/postprocessing/MaskPass.js"></script>
- <script src="js/shaders/CopyShader.js"></script>
- <script src="js/shaders/ColorCorrectionShader.js"></script>
- <script src="js/shaders/VignetteShader.js"></script>
-
- <script src="js/loaders/sea3d/SEA3D.js"></script>
- <script src="js/loaders/sea3d/SEA3DLZMA.js"></script>
- <script src="js/loaders/sea3d/SEA3DLoader.js"></script>
-
<script src="js/libs/ammo.js"></script>
- <script src="js/loaders/sea3d/physics/SEA3DRigidBody.js"></script>
- <script src="js/loaders/sea3d/physics/SEA3DAmmo.js"></script>
- <script src="js/loaders/sea3d/physics/SEA3DAmmoLoader.js"></script>
- <script src="js/WebGL.js"></script>
- <script src="js/libs/stats.min.js"></script>
+ <script type="module">
- <script>
+ import {
+ Vector3,
+ Color,
+ Clock,
+ PerspectiveCamera,
+ Scene,
+ WebGLRenderer
+ } from "../build/three.module.js";
- if ( WEBGL.isWebGLAvailable() === false ) {
+ import { OrbitControls } from './jsm/controls/OrbitControls.js';
- document.body.appendChild( WEBGL.getWebGLErrorMessage() );
+ import { EffectComposer } from './jsm/postprocessing/EffectComposer.js';
+ import { RenderPass } from './jsm/postprocessing/RenderPass.js';
+ import { ShaderPass } from './jsm/postprocessing/ShaderPass.js';
+ import { MaskPass } from './jsm/postprocessing/MaskPass.js';
+ import { CopyShader } from './jsm/shaders/CopyShader.js';
+ import { ColorCorrectionShader } from './jsm/shaders/ColorCorrectionShader.js';
+ import { VignetteShader } from './jsm/shaders/VignetteShader.js';
- }
+ import { SEA3D } from './jsm/loaders/sea3d/SEA3DLoader.js';
+ import { AMMO } from './jsm/loaders/sea3d/physics/SEA3DAmmoLoader.js'; // sea3d ammo.js extension
+ import './jsm/loaders/sea3d/SEA3DLZMA.js'; // sea3d lzma extension
+ import './jsm/loaders/sea3d/physics/SEA3DSDKRigidBody.js'; // sea3d physics extension
+
+ import Stats from './jsm/libs/stats.module.js';
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
@@ -62,21 +60,21 @@
// Initialize Physics Engine
Ammo = AmmoLib;
- SEA3D.AMMO.init();
+ AMMO.init();
//
// SEA3D Loader
//
- loader = new THREE.SEA3D( {
+ loader = new SEA3D( {
container: scene // Container to add models
} );
loader.onComplete = function () {
- new THREE.OrbitControls( camera, renderer.domElement );
+ new OrbitControls( camera, renderer.domElement );
// events
@@ -104,7 +102,7 @@
return function () {
- var domain = this.loader.clone( { lights: false, runScripts: false, autoPlay: false, enabledPhysics: false } );
+ var domain = loader.clone( { lights: false, runScripts: false, autoPlay: false, enabledPhysics: false } );
offset -= 180;
@@ -113,29 +111,28 @@
domain.enabledPhysics( true );
domain.runScripts();
- this.scene.add( domain.container );
+ scene.add( domain.container );
};
}();
-
} );
//
function init() {
- scene = new THREE.Scene();
- scene.background = new THREE.Color( 0x333333 );
+ scene = new Scene();
+ scene.background = new Color( 0x333333 );
container = document.createElement( 'div' );
document.body.appendChild( container );
- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 15000 );
+ camera = new PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 15000 );
camera.position.set( 300, 200, - 300 );
- renderer = new THREE.WebGLRenderer();
+ renderer = new WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
@@ -145,20 +142,20 @@
// post-processing
- composer = new THREE.EffectComposer( renderer );
+ composer = new EffectComposer( renderer );
- var renderPass = new THREE.RenderPass( scene, camera );
- var copyPass = new THREE.ShaderPass( THREE.CopyShader );
+ var renderPass = new RenderPass( scene, camera );
+ var copyPass = new ShaderPass( CopyShader );
composer.addPass( renderPass );
var vh = 1.4, vl = 1.2;
- var colorCorrectionPass = new THREE.ShaderPass( THREE.ColorCorrectionShader );
- colorCorrectionPass.uniforms[ "powRGB" ].value = new THREE.Vector3( vh, vh, vh );
- colorCorrectionPass.uniforms[ "mulRGB" ].value = new THREE.Vector3( vl, vl, vl );
+ var colorCorrectionPass = new ShaderPass( ColorCorrectionShader );
+ colorCorrectionPass.uniforms[ "powRGB" ].value = new Vector3( vh, vh, vh );
+ colorCorrectionPass.uniforms[ "mulRGB" ].value = new Vector3( vl, vl, vl );
composer.addPass( colorCorrectionPass );
- var vignettePass = new THREE.ShaderPass( THREE.VignetteShader );
+ var vignettePass = new ShaderPass( VignetteShader );
vignettePass.uniforms[ "darkness" ].value = 1.0;
composer.addPass( vignettePass );
@@ -182,7 +179,7 @@
//
- var clock = new THREE.Clock();
+ var clock = new Clock();
function animate() {
@@ -192,11 +189,11 @@
// Update Physics Engine ( fix delta-time in 60fps for more stability )
- SEA3D.AMMO.update( 1 / 60 );
+ AMMO.update( 1 / 60 );
// Update SEA3D Animations
- THREE.SEA3D.AnimationHandler.update( delta );
+ SEA3D.AnimationHandler.update( delta );
render( delta );
| true |
Other | mrdoob | three.js | 654fb5ed564429027d960494d1b1045a2351b436.json | update sea3d examples to modules | examples/webgl_loader_sea3d_skinning.html | @@ -14,32 +14,32 @@
<div id="playercount"></div>
</div>
- <script src="../build/three.js"></script>
+ <script type="module">
- <script src="js/controls/OrbitControls.js"></script>
+ import {
+ Vector3,
+ Color,
+ Clock,
+ Object3D,
+ PerspectiveCamera,
+ Scene,
+ WebGLRenderer
+ } from "../build/three.module.js";
- <script src="js/postprocessing/EffectComposer.js"></script>
- <script src="js/postprocessing/RenderPass.js"></script>
- <script src="js/postprocessing/ShaderPass.js"></script>
- <script src="js/postprocessing/MaskPass.js"></script>
- <script src="js/shaders/CopyShader.js"></script>
- <script src="js/shaders/ColorCorrectionShader.js"></script>
- <script src="js/shaders/VignetteShader.js"></script>
+ import { OrbitControls } from './jsm/controls/OrbitControls.js';
- <script src="js/loaders/sea3d/SEA3D.js"></script>
- <script src="js/loaders/sea3d/SEA3DLZMA.js"></script>
- <script src="js/loaders/sea3d/SEA3DLoader.js"></script>
+ import { EffectComposer } from './jsm/postprocessing/EffectComposer.js';
+ import { RenderPass } from './jsm/postprocessing/RenderPass.js';
+ import { ShaderPass } from './jsm/postprocessing/ShaderPass.js';
+ import { MaskPass } from './jsm/postprocessing/MaskPass.js';
+ import { CopyShader } from './jsm/shaders/CopyShader.js';
+ import { ColorCorrectionShader } from './jsm/shaders/ColorCorrectionShader.js';
+ import { VignetteShader } from './jsm/shaders/VignetteShader.js';
- <script src="js/WebGL.js"></script>
- <script src="js/libs/stats.min.js"></script>
+ import { SEA3D } from './jsm/loaders/sea3d/SEA3DLoader.js';
+ import './jsm/loaders/sea3d/SEA3DLZMA.js'; // sea3d lzma extension
- <script>
-
- if ( WEBGL.isWebGLAvailable() === false ) {
-
- document.body.appendChild( WEBGL.getWebGLErrorMessage() );
-
- }
+ import Stats from './jsm/libs/stats.module.js';
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
@@ -57,7 +57,7 @@
// SEA3D Loader
//
- loader = new THREE.SEA3D( {
+ loader = new SEA3D( {
autoPlay: true, // Auto play animations
container: scene, // Container to add models
@@ -74,7 +74,7 @@
camera.position.copy( cam.position );
camera.rotation.copy( cam.rotation );
- var controls = new THREE.OrbitControls( camera, renderer.domElement );
+ var controls = new OrbitControls( camera, renderer.domElement );
// get meshes
player = loader.getMesh( "Player" );
@@ -86,7 +86,7 @@
// or
- player.animation[ 'pass#1' ].addEventListener( THREE.SEA3D.Animation.COMPLETE, function ( e ) {
+ player.animation[ 'pass#1' ].addEventListener( SEA3D.Animation.COMPLETE, function ( e ) {
console.log( "Animation completed!", e );
@@ -122,7 +122,7 @@
var PHI = Math.PI * 2 * ( Math.sqrt( 5 ) + 1 ) / 2; // golden ratio
var angle = PHI * count ++;
- var container = new THREE.Object3D();
+ var container = new Object3D();
container.position.z = ( size * count ) * Math.cos( angle );
container.position.x = ( size * count ) * Math.sin( angle );
@@ -140,16 +140,16 @@
function init() {
- scene = new THREE.Scene();
- scene.background = new THREE.Color( 0x333333 );
+ scene = new Scene();
+ scene.background = new Color( 0x333333 );
container = document.createElement( 'div' );
document.body.appendChild( container );
- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 20000 );
+ camera = new PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 20000 );
camera.position.set( 1000, - 300, 1000 );
- renderer = new THREE.WebGLRenderer();
+ renderer = new WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
@@ -159,20 +159,20 @@
// post-processing
- composer = new THREE.EffectComposer( renderer );
+ composer = new EffectComposer( renderer );
- var renderPass = new THREE.RenderPass( scene, camera );
- var copyPass = new THREE.ShaderPass( THREE.CopyShader );
+ var renderPass = new RenderPass( scene, camera );
+ var copyPass = new ShaderPass( CopyShader );
composer.addPass( renderPass );
var vh = 1.4, vl = 1.2;
- var colorCorrectionPass = new THREE.ShaderPass( THREE.ColorCorrectionShader );
- colorCorrectionPass.uniforms[ "powRGB" ].value = new THREE.Vector3( vh, vh, vh );
- colorCorrectionPass.uniforms[ "mulRGB" ].value = new THREE.Vector3( vl, vl, vl );
+ var colorCorrectionPass = new ShaderPass( ColorCorrectionShader );
+ colorCorrectionPass.uniforms[ "powRGB" ].value = new Vector3( vh, vh, vh );
+ colorCorrectionPass.uniforms[ "mulRGB" ].value = new Vector3( vl, vl, vl );
composer.addPass( colorCorrectionPass );
- var vignettePass = new THREE.ShaderPass( THREE.VignetteShader );
+ var vignettePass = new ShaderPass( VignetteShader );
vignettePass.uniforms[ "darkness" ].value = 1.0;
composer.addPass( vignettePass );
@@ -222,7 +222,7 @@
//
- var clock = new THREE.Clock();
+ var clock = new Clock();
function animate() {
@@ -231,7 +231,7 @@
requestAnimationFrame( animate );
// Update SEA3D Animations
- THREE.SEA3D.AnimationHandler.update( delta );
+ SEA3D.AnimationHandler.update( delta );
render( delta );
| true |
Other | mrdoob | three.js | 654fb5ed564429027d960494d1b1045a2351b436.json | update sea3d examples to modules | examples/webgl_loader_sea3d_sound.html | @@ -57,32 +57,35 @@
</div>
- <script src="../build/three.js"></script>
-
- <script src="js/controls/PointerLockControls.js"></script>
-
- <script src="js/postprocessing/EffectComposer.js"></script>
- <script src="js/postprocessing/RenderPass.js"></script>
- <script src="js/postprocessing/ShaderPass.js"></script>
- <script src="js/postprocessing/MaskPass.js"></script>
- <script src="js/shaders/CopyShader.js"></script>
- <script src="js/shaders/ColorCorrectionShader.js"></script>
- <script src="js/shaders/VignetteShader.js"></script>
-
- <script src="js/loaders/sea3d/SEA3D.js"></script>
- <script src="js/loaders/sea3d/SEA3DLZMA.js"></script>
- <script src="js/loaders/sea3d/SEA3DLoader.js"></script>
-
- <script src="js/WebGL.js"></script>
- <script src="js/libs/stats.min.js"></script>
-
- <script>
-
- if ( WEBGL.isWebGLAvailable() === false ) {
-
- document.body.appendChild( WEBGL.getWebGLErrorMessage() );
-
- }
+ <script type="module">
+
+ import {
+ Vector3,
+ Color,
+ Euler,
+ Clock,
+ AudioAnalyser,
+ AudioLoader,
+ Raycaster,
+ PerspectiveCamera,
+ Scene,
+ WebGLRenderer
+ } from "../build/three.module.js";
+
+ import { PointerLockControls } from './jsm/controls/PointerLockControls.js';
+
+ import { EffectComposer } from './jsm/postprocessing/EffectComposer.js';
+ import { RenderPass } from './jsm/postprocessing/RenderPass.js';
+ import { ShaderPass } from './jsm/postprocessing/ShaderPass.js';
+ import { MaskPass } from './jsm/postprocessing/MaskPass.js';
+ import { CopyShader } from './jsm/shaders/CopyShader.js';
+ import { ColorCorrectionShader } from './jsm/shaders/ColorCorrectionShader.js';
+ import { VignetteShader } from './jsm/shaders/VignetteShader.js';
+
+ import { SEA3D } from './jsm/loaders/sea3d/SEA3DLoader.js';
+ import './jsm/loaders/sea3d/SEA3DLZMA.js'; // sea3d lzma extension
+
+ import Stats from './jsm/libs/stats.module.js';
console.log( "Visit https://github.com/sunag/sea3d to all codes and builds under development." );
@@ -105,7 +108,7 @@
// SEA3D Loader
//
- loader = new THREE.SEA3D( {
+ loader = new SEA3D( {
autoPlay: true, // Auto play animations
container: scene // Container to add models
@@ -128,14 +131,14 @@
lightOutside = loader.getLight( "Light1" );
var soundOutside = loader.getSound3D( "Point001" );
- soundOutsideAnalyser = new THREE.AudioAnalyser( soundOutside, 32 );
+ soundOutsideAnalyser = new AudioAnalyser( soundOutside, 32 );
// sound asset 2 + area
lightArea = loader.getLight( "Light2" );
soundArea = loader.getSound3D( "Point002" );
- soundAreaAnalyser = new THREE.AudioAnalyser( soundArea, 512 );
+ soundAreaAnalyser = new AudioAnalyser( soundArea, 512 );
collisionArea = loader.getMesh( "Torus003" );
@@ -280,25 +283,25 @@
function init() {
- raycaster = new THREE.Raycaster();
+ raycaster = new Raycaster();
- scene = new THREE.Scene();
- scene.background = new THREE.Color( 0x333333 );
+ scene = new Scene();
+ scene.background = new Color( 0x333333 );
- velocity = new THREE.Vector3();
+ velocity = new Vector3();
container = document.createElement( 'div' );
document.body.appendChild( container );
- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
+ camera = new PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
- controls = new THREE.PointerLockControls( camera );
+ controls = new PointerLockControls( camera );
scene.add( controls.getObject() );
controls.getObject().translateX( 250 );
controls.getObject().translateZ( 250 );
- renderer = new THREE.WebGLRenderer();
+ renderer = new WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
@@ -308,20 +311,20 @@
// post-processing
- composer = new THREE.EffectComposer( renderer );
+ composer = new EffectComposer( renderer );
- var renderPass = new THREE.RenderPass( scene, camera );
- var copyPass = new THREE.ShaderPass( THREE.CopyShader );
+ var renderPass = new RenderPass( scene, camera );
+ var copyPass = new ShaderPass( CopyShader );
composer.addPass( renderPass );
var vh = 1.4, vl = 1.2;
- var colorCorrectionPass = new THREE.ShaderPass( THREE.ColorCorrectionShader );
- colorCorrectionPass.uniforms[ "powRGB" ].value = new THREE.Vector3( vh, vh, vh );
- colorCorrectionPass.uniforms[ "mulRGB" ].value = new THREE.Vector3( vl, vl, vl );
+ var colorCorrectionPass = new ShaderPass( ColorCorrectionShader );
+ colorCorrectionPass.uniforms[ "powRGB" ].value = new Vector3( vh, vh, vh );
+ colorCorrectionPass.uniforms[ "mulRGB" ].value = new Vector3( vl, vl, vl );
composer.addPass( colorCorrectionPass );
- var vignettePass = new THREE.ShaderPass( THREE.VignetteShader );
+ var vignettePass = new ShaderPass( VignetteShader );
vignettePass.uniforms[ "darkness" ].value = 1.0;
composer.addPass( vignettePass );
@@ -366,14 +369,14 @@
}
- var clock = new THREE.Clock();
- var audioPos = new THREE.Vector3();
- var audioRot = new THREE.Euler();
+ var clock = new Clock();
+ var audioPos = new Vector3();
+ var audioRot = new Euler();
function updateSoundFilter() {
// difference position between sound and listener
- var difPos = new THREE.Vector3().setFromMatrixPosition( soundArea.matrixWorld ).sub( audioPos );
+ var difPos = new Vector3().setFromMatrixPosition( soundArea.matrixWorld ).sub( audioPos );
var length = difPos.length();
// pick a vector from camera to sound
@@ -412,7 +415,7 @@
lightArea.intensity = soundAreaAnalyser.getAverageFrequency() / 50;
// Update SEA3D Animations
- THREE.SEA3D.AnimationHandler.update( delta );
+ SEA3D.AnimationHandler.update( delta );
render( delta );
| true |
Other | mrdoob | three.js | 68080d3af0bd208273ad8a6d3c75e0097e195c3c.json | fix LGTM Errors | examples/js/loaders/AWDLoader.js | @@ -49,6 +49,8 @@ THREE.AWDLoader = ( function () {
this.id = 0;
this.data = null;
+ this.namespace = 0;
+ this.flags = 0;
}
@@ -167,7 +169,7 @@ THREE.AWDLoader = ( function () {
parseNextBlock: function () {
var assetData,
- ns, type, len, block,
+ block,
blockId = this.readU32(),
ns = this.readU8(),
type = this.readU8(),
@@ -233,6 +235,8 @@ THREE.AWDLoader = ( function () {
this._blocks[ blockId ] = block = new Block();
block.data = assetData;
block.id = blockId;
+ block.namespace = ns;
+ block.flags = flags;
},
@@ -401,7 +405,8 @@ THREE.AWDLoader = ( function () {
while ( methods_parsed < num_methods ) {
- var method_type = this.readU16();
+ // read method_type before
+ this.readU16();
this.parseProperties( null );
this.parseUserAttributes();
@@ -454,7 +459,9 @@ THREE.AWDLoader = ( function () {
var url = this.readUTFBytes( data_len );
console.log( url );
- asset = this.loadTexture( url );
+ asset = this.loadTexture(url);
+ asset.userData = {};
+ asset.userData.name = name;
} else {
// embed texture not supported
@@ -487,8 +494,9 @@ THREE.AWDLoader = ( function () {
parseSkeleton: function () {
// Array<Bone>
- var name = this.readUTF(),
- num_joints = this.readU16(),
+ //
+ this.readUTF();
+ var num_joints = this.readU16(),
skeleton = [],
joints_parsed = 0;
| false |
Other | mrdoob | three.js | dc87b9108857ea1a56319cca424bd1580628b6b3.json | Fix code style | src/core/InstancedBufferGeometry.js | @@ -35,14 +35,16 @@ InstancedBufferGeometry.prototype = Object.assign( Object.create( BufferGeometry
},
- toJSON: function(){
+ toJSON: function () {
+
var data = BufferGeometry.prototype.toJSON.call( this );
data.maxInstancedCount = this.maxInstancedCount;
data.isInstancedBufferGeometry = true;
return data;
+
}
} ); | false |
Other | mrdoob | three.js | ad45315adf6d6afd77c39ad55e68b05d706d0d82.json | Enable premultiplied alpha | examples/js/loaders/LDrawLoader.js | @@ -1268,6 +1268,7 @@ THREE.LDrawLoader = ( function () {
}
material.transparent = isTransparent;
+ material.premultipliedAlpha = true;
material.opacity = alpha;
material.userData.canHaveEnvMap = canHaveEnvMap; | false |
Other | mrdoob | three.js | 0c08f4f0018b9619e1b87dd44d4373007b67faa3.json | prevent unexpected vertex weighting | examples/js/loaders/LDrawLoader.js | @@ -66,6 +66,13 @@ THREE.LDrawLoader = ( function () {
}
+ // NOTE: Some of the normals wind up being skewed in an unexpected way because
+ // quads provide more "influence" to some vertex normals than a triangle due to
+ // the fact that a quad is made up of two triangles and all triangles are weighted
+ // equally. To fix this quads could be tracked separately so their vertex normals
+ // are weighted appropriately or we could try only adding a normal direction
+ // once per normal.
+
// Iterate until we've tried to connect all triangles to share normals
while ( true ) {
@@ -150,11 +157,22 @@ THREE.LDrawLoader = ( function () {
var otherHash = hashEdge( otherV0, otherV1 );
if ( otherHash === reverseHash ) {
- otherTri[ `n${ otherIndex }` ] = tri[ `n${ next }` ];
- otherTri[ `n${ otherNext }` ] = tri[ `n${ index }` ];
+ if ( otherTri[ `n${ otherIndex }` ] === null ) {
+
+ var norm = tri[ `n${ next }` ];
+ otherTri[ `n${ otherIndex }` ] = norm;
+ norm.add( otherTri.faceNormal );
+
+ }
+
+ if ( otherTri[ `n${ otherNext }` ] === null ) {
+
+ var norm = tri[ `n${ index }` ];
+ otherTri[ `n${ otherNext }` ] = norm;
+ norm.add( otherTri.faceNormal );
+
+ }
- tri[ `n${ next }` ].add( otherTri.faceNormal );
- tri[ `n${ index }` ].add( otherTri.faceNormal );
break;
} | false |
Other | mrdoob | three.js | 2131b112e74e04c764b5a6960b4a5760b4fb49bc.json | Add first pass at shader | examples/js/loaders/LDrawLoader.js | @@ -7,6 +7,83 @@
THREE.LDrawLoader = ( function () {
+ var optionalLineVertShader = /* glsl */`
+ attribute vec3 optionalControl0;
+ attribute vec3 optionalControl1;
+ attribute vec3 point0;
+ attribute vec3 point1;
+
+ varying vec4 controlOut0;
+ varying vec4 controlOut1;
+ varying vec4 pointOut0;
+ varying vec4 pointOut1;
+ #include <common>
+ #include <color_pars_vertex>
+ #include <fog_pars_vertex>
+ #include <logdepthbuf_pars_vertex>
+ #include <clipping_planes_pars_vertex>
+ void main() {
+ #include <color_vertex>
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
+ gl_Position = projectionMatrix * mvPosition;
+
+ controlOut0 = projectionMatrix * modelViewMatrix * vec4( optionalControl0, 1.0 );
+ controlOut1 = projectionMatrix * modelViewMatrix * vec4( optionalControl1, 1.0 );
+ pointOut0 = projectionMatrix * modelViewMatrix * vec4( point0, 1.0 );
+ pointOut1 = projectionMatrix * modelViewMatrix * vec4( point1, 1.0 );
+
+ #include <logdepthbuf_vertex>
+ #include <clipping_planes_vertex>
+ #include <fog_vertex>
+ }
+ `;
+
+ var optionalLineFragShader = /* glsl */`
+ uniform vec3 diffuse;
+ uniform float opacity;
+ varying vec4 controlOut0;
+ varying vec4 controlOut1;
+ varying vec4 pointOut0;
+ varying vec4 pointOut1;
+
+ #include <common>
+ #include <color_pars_fragment>
+ #include <fog_pars_fragment>
+ #include <logdepthbuf_pars_fragment>
+ #include <clipping_planes_pars_fragment>
+ void main() {
+
+ vec2 c0 = controlOut0.xy / controlOut0.w;
+ vec2 c1 = controlOut1.xy / controlOut1.w;
+ vec2 p0 = pointOut0.xy / pointOut0.w;
+ vec2 p1 = pointOut1.xy / pointOut1.w;
+ vec2 dir = p1 - p0;
+ vec2 norm = vec2( -dir.y, dir.x );
+
+ vec2 c0dir = c0 - p1;
+ vec2 c1dir = c1 - p1;
+
+ float d0 = dot( normalize( norm ), normalize( c0dir ) );
+ float d1 = dot( normalize( norm ), normalize( c1dir ) );
+
+ if ( sign( d0 ) != sign( d1 ) ) discard;
+
+ #include <clipping_planes_fragment>
+ vec3 outgoingLight = vec3( 0.0 );
+ vec4 diffuseColor = vec4( diffuse, opacity );
+ #include <logdepthbuf_fragment>
+ #include <color_fragment>
+ outgoingLight = diffuseColor.rgb; // simple shader
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );
+ #include <premultiplied_alpha_fragment>
+ #include <tonemapping_fragment>
+ #include <encodings_fragment>
+ #include <fog_fragment>
+ }
+ `;
+
+
+
var tempVec0 = new THREE.Vector3();
var tempVec1 = new THREE.Vector3();
function smoothNormals( triangles, lineSegments ) {
@@ -548,9 +625,76 @@ THREE.LDrawLoader = ( function () {
if ( parseScope.conditionalSegments.length > 0 ) {
- var lines = createObject( parseScope.conditionalSegments, 2 );
+ var conditionalSegments = parseScope.conditionalSegments;
+ var lines = createObject( conditionalSegments, 2 );
lines.isConditionalLine = true;
lines.visible = false;
+
+ var controlArray0 = new Float32Array( conditionalSegments.length * 3 * 2 );
+ var controlArray1 = new Float32Array( conditionalSegments.length * 3 * 2 );
+ var pointArray0 = new Float32Array( conditionalSegments.length * 3 * 2 );
+ var pointArray1 = new Float32Array( conditionalSegments.length * 3 * 2 );
+ for ( var i = 0, l = conditionalSegments.length; i < l; i ++ ) {
+
+ var os = conditionalSegments[ i ];
+ var c0 = os.c0;
+ var c1 = os.c1;
+ var v0 = os.v0;
+ var v1 = os.v1;
+ var index = i * 3 * 2;
+ controlArray0[ index + 0 ] = c0.x;
+ controlArray0[ index + 1 ] = c0.y;
+ controlArray0[ index + 2 ] = c0.z;
+ controlArray0[ index + 3 ] = c0.x;
+ controlArray0[ index + 4 ] = c0.y;
+ controlArray0[ index + 5 ] = c0.z;
+
+ controlArray1[ index + 0 ] = c1.x;
+ controlArray1[ index + 1 ] = c1.y;
+ controlArray1[ index + 2 ] = c1.z;
+ controlArray1[ index + 3 ] = c1.x;
+ controlArray1[ index + 4 ] = c1.y;
+ controlArray1[ index + 5 ] = c1.z;
+
+ pointArray0[ index + 0 ] = v0.x;
+ pointArray0[ index + 1 ] = v0.y;
+ pointArray0[ index + 2 ] = v0.z;
+ pointArray0[ index + 3 ] = v0.x;
+ pointArray0[ index + 4 ] = v0.y;
+ pointArray0[ index + 5 ] = v0.z;
+
+ pointArray1[ index + 0 ] = v1.x;
+ pointArray1[ index + 1 ] = v1.y;
+ pointArray1[ index + 2 ] = v1.z;
+ pointArray1[ index + 3 ] = v1.x;
+ pointArray1[ index + 4 ] = v1.y;
+ pointArray1[ index + 5 ] = v1.z;
+
+ }
+
+ lines.geometry.addAttribute( 'optionalControl0', new THREE.BufferAttribute( controlArray0, 3, false ) );
+ lines.geometry.addAttribute( 'optionalControl1', new THREE.BufferAttribute( controlArray1, 3, false ) );
+ lines.geometry.addAttribute( 'point0', new THREE.BufferAttribute( pointArray0, 3, false ) );
+ lines.geometry.addAttribute( 'point1', new THREE.BufferAttribute( pointArray1, 3, false ) );
+
+ lines.material = lines.material.map( mat => {
+
+ return new THREE.ShaderMaterial( {
+ vertexShader: optionalLineVertShader,
+ fragmentShader: optionalLineFragShader,
+ uniforms: {
+ diffuse: {
+ value: mat.color
+ },
+ opacity: {
+ value: mat.opacity
+ }
+ }
+ } );
+
+ } );
+
+
objGroup.add( lines );
}
@@ -597,6 +741,8 @@ THREE.LDrawLoader = ( function () {
os.v0.applyMatrix4( parseScope.matrix );
os.v1.applyMatrix4( parseScope.matrix );
+ os.c0.applyMatrix4( parseScope.matrix );
+ os.c1.applyMatrix4( parseScope.matrix );
}
parentConditionalSegments.push( os );
@@ -1530,12 +1676,21 @@ THREE.LDrawLoader = ( function () {
var material = parseColourCode( lp, true );
var arr = lineType === '2' ? lineSegments : conditionalSegments;
- arr.push( {
+ var segment = {
material: material.userData.edgeMaterial,
colourCode: material.userData.code,
v0: parseVector( lp ),
v1: parseVector( lp )
- } );
+ };
+
+ if ( lineType === '5' ) {
+
+ segment.c0 = parseVector( lp );
+ segment.c1 = parseVector( lp );
+
+ }
+
+ arr.push( segment );
break;
| false |
Other | mrdoob | three.js | 5bfe1047ff1d3e06d98bc86e6fee5942e7ace23c.json | Hide conditional lines by default | examples/js/loaders/LDrawLoader.js | @@ -550,16 +550,17 @@ THREE.LDrawLoader = ( function () {
var lines = createObject( parseScope.conditionalSegments, 2 );
lines.isConditionalLine = true;
+ lines.visible = false;
objGroup.add( lines );
}
if ( parentParseScope.groupObject ) {
objGroup.name = parseScope.fileName;
- objGroup.matrix.copy( parseScope.matrix );
objGroup.matrix.decompose( objGroup.position, objGroup.quaternion, objGroup.scale );
- objGroup.matrixAutoUpdate = false;
+ objGroup.userData.category = parseScope.category;
+ objGroup.userData.keywords = parseScope.keywords;
parentParseScope.groupObject.add( objGroup );
@@ -822,6 +823,8 @@ THREE.LDrawLoader = ( function () {
numSubobjects: 0,
subobjectIndex: 0,
inverted: false,
+ category: null,
+ keywords: null,
// Current subobject
currentFileName: null, | false |
Other | mrdoob | three.js | add08253d3962f0b1e234b54cf921327a7bee3c4.json | remove morph target changes | examples/jsm/loaders/FBXLoader.js | @@ -1590,11 +1590,12 @@ var FBXLoader = ( function () {
},
+
// Parse single node mesh geometry in FBXTree.Objects.Geometry
parseMeshGeometry: function ( relationships, geoNode, deformers ) {
var skeletons = deformers.skeletons;
- var morphTargets = [];
+ var morphTargets = deformers.morphTargets;
var modelNodes = relationships.parents.map( function ( parent ) {
@@ -1613,15 +1614,13 @@ var FBXLoader = ( function () {
}, null );
- relationships.children.forEach( function( child ) {
-
- if ( deformers.morphTargets[ child.ID ] !== undefined ) {
+ var morphTarget = relationships.children.reduce( function ( morphTarget, child ) {
- morphTargets.push( deformers.morphTargets[ child.ID ] );
+ if ( morphTargets[ child.ID ] !== undefined ) morphTarget = morphTargets[ child.ID ];
- }
+ return morphTarget;
- } );
+ }, null );
// Assume one model and get the preRotation from that
// if there is more than one model associated with the geometry this may cause problems
@@ -1638,12 +1637,12 @@ var FBXLoader = ( function () {
var transform = generateTransform( transformData );
- return this.genGeometry( geoNode, skeleton, morphTargets, transform );
+ return this.genGeometry( geoNode, skeleton, morphTarget, transform );
},
// Generate a BufferGeometry from a node in FBXTree.Objects.Geometry
- genGeometry: function ( geoNode, skeleton, morphTargets, preTransform ) {
+ genGeometry: function ( geoNode, skeleton, morphTarget, preTransform ) {
var geo = new BufferGeometry();
if ( geoNode.attrName ) geo.name = geoNode.attrName;
@@ -1744,7 +1743,7 @@ var FBXLoader = ( function () {
}
- this.addMorphTargets( geo, geoNode, morphTargets, preTransform );
+ this.addMorphTargets( geo, geoNode, morphTarget, preTransform );
return geo;
@@ -2117,27 +2116,23 @@ var FBXLoader = ( function () {
},
- addMorphTargets: function ( parentGeo, parentGeoNode, morphTargets, preTransform ) {
+ addMorphTargets: function ( parentGeo, parentGeoNode, morphTarget, preTransform ) {
- if ( morphTargets.length === 0 ) return;
+ if ( morphTarget === null ) return;
parentGeo.morphAttributes.position = [];
// parentGeo.morphAttributes.normal = []; // not implemented
- var self = this;
- morphTargets.forEach( function( morphTarget ) {
-
- morphTarget.rawTargets.forEach( function ( rawTarget ) {
-
- var morphGeoNode = fbxTree.Objects.Geometry[ rawTarget.geoID ];
+ var self = this;
+ morphTarget.rawTargets.forEach( function ( rawTarget ) {
- if ( morphGeoNode !== undefined ) {
+ var morphGeoNode = fbxTree.Objects.Geometry[ rawTarget.geoID ];
- self.genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform, rawTarget.name );
+ if ( morphGeoNode !== undefined ) {
- }
+ self.genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform, rawTarget.name );
- } );
+ }
} );
@@ -2149,7 +2144,6 @@ var FBXLoader = ( function () {
// Normal and position attributes only have data for the vertices that are affected by the morph
genMorphGeometry: function ( parentGeo, parentGeoNode, morphGeoNode, preTransform, name ) {
- console.log(parentGeo, parentGeoNode, morphGeoNode, preTransform, name);
var morphGeo = new BufferGeometry();
if ( morphGeoNode.attrName ) morphGeo.name = morphGeoNode.attrName;
| false |
Other | mrdoob | three.js | 6406684fdfd294f7523c05fe2967727a6dd368e8.json | remove morph target changes | examples/js/loaders/FBXLoader.js | @@ -1542,11 +1542,12 @@ THREE.FBXLoader = ( function () {
},
+
// Parse single node mesh geometry in FBXTree.Objects.Geometry
parseMeshGeometry: function ( relationships, geoNode, deformers ) {
var skeletons = deformers.skeletons;
- var morphTargets = [];
+ var morphTargets = deformers.morphTargets;
var modelNodes = relationships.parents.map( function ( parent ) {
@@ -1565,15 +1566,13 @@ THREE.FBXLoader = ( function () {
}, null );
- relationships.children.forEach( function( child ) {
-
- if ( deformers.morphTargets[ child.ID ] !== undefined ) {
+ var morphTarget = relationships.children.reduce( function ( morphTarget, child ) {
- morphTargets.push( deformers.morphTargets[ child.ID ] );
+ if ( morphTargets[ child.ID ] !== undefined ) morphTarget = morphTargets[ child.ID ];
- }
+ return morphTarget;
- } );
+ }, null );
// Assume one model and get the preRotation from that
// if there is more than one model associated with the geometry this may cause problems
@@ -1590,12 +1589,12 @@ THREE.FBXLoader = ( function () {
var transform = generateTransform( transformData );
- return this.genGeometry( geoNode, skeleton, morphTargets, transform );
+ return this.genGeometry( geoNode, skeleton, morphTarget, transform );
},
// Generate a THREE.BufferGeometry from a node in FBXTree.Objects.Geometry
- genGeometry: function ( geoNode, skeleton, morphTargets, preTransform ) {
+ genGeometry: function ( geoNode, skeleton, morphTarget, preTransform ) {
var geo = new THREE.BufferGeometry();
if ( geoNode.attrName ) geo.name = geoNode.attrName;
@@ -1696,7 +1695,7 @@ THREE.FBXLoader = ( function () {
}
- this.addMorphTargets( geo, geoNode, morphTargets, preTransform );
+ this.addMorphTargets( geo, geoNode, morphTarget, preTransform );
return geo;
@@ -2069,27 +2068,23 @@ THREE.FBXLoader = ( function () {
},
- addMorphTargets: function ( parentGeo, parentGeoNode, morphTargets, preTransform ) {
+ addMorphTargets: function ( parentGeo, parentGeoNode, morphTarget, preTransform ) {
- if ( morphTargets.length === 0 ) return;
+ if ( morphTarget === null ) return;
parentGeo.morphAttributes.position = [];
// parentGeo.morphAttributes.normal = []; // not implemented
- var self = this;
- morphTargets.forEach( function( morphTarget ) {
-
- morphTarget.rawTargets.forEach( function ( rawTarget ) {
-
- var morphGeoNode = fbxTree.Objects.Geometry[ rawTarget.geoID ];
+ var self = this;
+ morphTarget.rawTargets.forEach( function ( rawTarget ) {
- if ( morphGeoNode !== undefined ) {
+ var morphGeoNode = fbxTree.Objects.Geometry[ rawTarget.geoID ];
- self.genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform, rawTarget.name );
+ if ( morphGeoNode !== undefined ) {
- }
+ self.genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform, rawTarget.name );
- } );
+ }
} );
@@ -2101,7 +2096,6 @@ THREE.FBXLoader = ( function () {
// Normal and position attributes only have data for the vertices that are affected by the morph
genMorphGeometry: function ( parentGeo, parentGeoNode, morphGeoNode, preTransform, name ) {
- console.log(parentGeo, parentGeoNode, morphGeoNode, preTransform, name);
var morphGeo = new THREE.BufferGeometry();
if ( morphGeoNode.attrName ) morphGeo.name = morphGeoNode.attrName;
| false |
Other | mrdoob | three.js | 1aa70297edd063e397a250f6dcbfe53524abebd8.json | Fix breakage on Chrome 73 | examples/js/vr/HelioWebXRPolyfill.js | @@ -72,7 +72,7 @@ if ( /(Helio)/g.test( navigator.userAgent ) && "xr" in navigator ) {
// WebXRManager - xrFrame.getPose() Polyfill - line 259
- const tempGetPose = frame.getPose.bind( frame );
+ const tempGetPose = (isHelio96 ? null : frame.getPose.bind( frame ));
frame.getPose = function ( targetRaySpace, referenceSpace ) {
| false |
Other | mrdoob | three.js | f1ba3a32ed065887364328c6d8b9168eee761be0.json | Remove indent size from .editorconfig | .editorconfig | @@ -9,7 +9,6 @@ insert_final_newline = true
[*.{js,ts,html}]
charset = utf-8
indent_style = tab
-indent_size = 2
[*.{js,ts}]
trim_trailing_whitespace = true | false |
Other | mrdoob | three.js | ce7287e4354f959205f89c177d5f928660d7cc33.json | Specify output type | examples/webgl_loader_gltf.html | @@ -53,13 +53,10 @@
scene = new THREE.Scene();
- var loader = new THREE.RGBELoader().setPath( 'textures/equirectangular/' );
- loader.load( 'pedestrian_overpass_2k.hdr', function ( texture ) {
-
- texture.encoding = THREE.RGBEEncoding;
- texture.minFilter = THREE.NearestFilter;
- texture.magFilter = THREE.NearestFilter;
- texture.flipY = true;
+ new THREE.RGBELoader()
+ .setType( THREE.UnsignedByteType )
+ .setPath( 'textures/equirectangular/' )
+ .load( 'pedestrian_overpass_2k.hdr', function ( texture ) {
var cubeGenerator = new THREE.EquirectangularToCubeGenerator( texture, { resolution: 1024 } );
cubeGenerator.update( renderer ); | true |
Other | mrdoob | three.js | ce7287e4354f959205f89c177d5f928660d7cc33.json | Specify output type | examples/webgl_loader_gltf_extensions.html | @@ -154,13 +154,10 @@
// Load background and generate envMap
- var loader = new THREE.RGBELoader().setPath( 'textures/equirectangular/' );
- loader.load( 'venice_sunset_2k.hdr', function ( texture ) {
-
- texture.encoding = THREE.RGBEEncoding;
- texture.minFilter = THREE.NearestFilter;
- texture.magFilter = THREE.NearestFilter;
- texture.flipY = true;
+ new THREE.RGBELoader()
+ .setType( THREE.UnsignedByteType )
+ .setPath( 'textures/equirectangular/' )
+ .load( 'venice_sunset_2k.hdr', function ( texture ) {
var cubeGenerator = new THREE.EquirectangularToCubeGenerator( texture, { resolution: 1024 } );
cubeGenerator.update( renderer ); | true |
Other | mrdoob | three.js | ce7287e4354f959205f89c177d5f928660d7cc33.json | Specify output type | examples/webgl_loader_texture_hdr.html | @@ -55,7 +55,7 @@
camera = new THREE.OrthographicCamera( - aspect, aspect, 1, - 1, 0, 1 );
new THREE.RGBELoader()
- .setType( THREE.UnsignedByteType ) // alt: THREE.FloatType
+ .setType( THREE.UnsignedByteType ) // alt: THREE.FloatType, THREE.HalfFloatType
.load( 'textures/memorial.hdr', function ( texture, textureData ) {
//console.log( textureData ); | true |
Other | mrdoob | three.js | 274b5ddbc46367803e54e706950bb8ad9ea7097b.json | Implement mipmap support in BasisTextureLoader
This change makes sure that we load all mipmaps present in the .basis
file. This is important for multiple reasons, one of them being that to
use .basis files in glTF out of the box, the texture has to have a
complete mipchain (otherwise the texture is incomplete as per WebGL spec
and sampling this texture returns (0,0,0)).
Contributes to #16524. | examples/js/loaders/BasisTextureLoader.js | @@ -117,9 +117,7 @@ THREE.BasisTextureLoader = class BasisTextureLoader {
var config = this.workerConfig;
- var { data, width, height } = message;
-
- var mipmaps = [ { data, width, height } ];
+ var { width, height, mipmaps } = message;
var texture;
@@ -305,9 +303,17 @@ THREE.BasisTextureLoader.BasisWorker = function () {
case 'transcode':
transcoderPending.then( () => {
- var { data, width, height } = transcode( message.buffer );
+ var { width, height, mipmaps } = transcode( message.buffer );
+
+ var buffers = [];
+
+ for ( var i = 0; i < mipmaps.length; ++i ) {
+
+ buffers.push( mipmaps[i].data.buffer );
+
+ }
- self.postMessage( { type: 'transcode', id: message.id, data, width, height }, [ data.buffer ] );
+ self.postMessage( { type: 'transcode', id: message.id, width, height, mipmaps }, buffers );
} );
break;
@@ -348,7 +354,6 @@ THREE.BasisTextureLoader.BasisWorker = function () {
var width = basisFile.getImageWidth( 0, 0 );
var height = basisFile.getImageHeight( 0, 0 );
- var images = basisFile.getNumImages();
var levels = basisFile.getNumLevels( 0 );
function cleanup () {
@@ -358,7 +363,7 @@ THREE.BasisTextureLoader.BasisWorker = function () {
}
- if ( ! width || ! height || ! images || ! levels ) {
+ if ( ! width || ! height || ! levels ) {
cleanup();
throw new Error( 'THREE.BasisTextureLoader: Invalid .basis file' );
@@ -372,28 +377,37 @@ THREE.BasisTextureLoader.BasisWorker = function () {
}
- var dst = new Uint8Array( basisFile.getImageTranscodedSizeInBytes( 0, 0, config.format ) );
+ var mipmaps = [];
- var startTime = performance.now();
+ for ( var mip = 0; mip < levels; mip++ ) {
- var status = basisFile.transcodeImage(
- dst,
- 0,
- 0,
- config.format,
- config.etcSupported ? 0 : ( config.dxtSupported ? 1 : 0 ),
- 0
- );
+ var mipWidth = basisFile.getImageWidth( 0, mip );
+ var mipHeight = basisFile.getImageHeight( 0, mip );
+ var dst = new Uint8Array( basisFile.getImageTranscodedSizeInBytes( 0, mip, config.format ) );
- cleanup();
+ var status = basisFile.transcodeImage(
+ dst,
+ 0,
+ mip,
+ config.format,
+ config.etcSupported ? 0 : ( config.dxtSupported ? 1 : 0 ),
+ 0
+ );
+
+ if ( ! status ) {
+
+ cleanup();
+ throw new Error( 'THREE.BasisTextureLoader: .transcodeImage failed.' );
- if ( ! status ) {
+ }
- throw new Error( 'THREE.BasisTextureLoader: .transcodeImage failed.' );
+ mipmaps.push( { data: dst, width: mipWidth, height: mipHeight } );
}
- return { data: dst, width, height };
+ cleanup();
+
+ return { width, height, mipmaps };
}
| false |
Other | mrdoob | three.js | f035349d9deed70872f46e7b11af4a7631533f91.json | Remove temporary variables. | src/geometries/ExtrudeGeometry.js | @@ -396,8 +396,7 @@ function ExtrudeBufferGeometry( shapes, options ) {
t = b / bevelSegments;
z = bevelThickness * Math.cos( t * Math.PI / 2 );
- var s = Math.sin( t * Math.PI / 2 );
- bs = bevelSize * s + bevelBaseSize;
+ bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelBaseSize;
// contract shape
@@ -495,8 +494,7 @@ function ExtrudeBufferGeometry( shapes, options ) {
t = b / bevelSegments;
z = bevelThickness * Math.cos( t * Math.PI / 2 );
- var s = Math.sin( t * Math.PI / 2 );
- bs = bevelSize * s + bevelBaseSize;
+ bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelBaseSize;
// contract shape
| false |
Other | mrdoob | three.js | c191afb0e1ff7fb8666fb61777d62569744a1a21.json | Fix a bug in GLTFExporter | examples/js/exporters/GLTFExporter.js | @@ -1377,7 +1377,7 @@ THREE.GLTFExporter.prototype = {
var key = getUID( geometry.index );
- if ( groups[ i ].start !== undefined || groups[ i ] !== undefined ) {
+ if ( groups[ i ].start !== undefined || groups[ i ].count !== undefined ) {
key += ':' + groups[ i ].start + ':' + groups[ i ].count;
| false |
Other | mrdoob | three.js | 6e9861b48e727e71b8372104164042ad43d168cc.json | Support hemisphere light probe | src/lights/LightProbe.js | @@ -28,6 +28,45 @@ LightProbe.prototype = Object.assign( Object.create( Light.prototype ), {
isLightProbe: true,
+ setAmbientProbe: function ( color, intensity ) {
+
+ this.color.set( color );
+
+ this.intensity = intensity !== undefined ? intensity : 1;
+
+ this.sh.zero();
+
+ // without extra factor of PI in the shader, would be 2 / Math.sqrt( Math.PI );
+ this.sh.coefficients[ 0 ].set( 1, 1, 1 ).multiplyScalar( 2 * Math.sqrt( Math.PI ) );
+
+ },
+
+ setHemisphereProbe: function ( skyColor, groundColor, intensity ) {
+
+ // up-direction hardwired
+
+ this.color.setHex( 0xffffff );
+
+ this.intensity = intensity !== undefined ? intensity : 1;
+
+ var sky = new Color( skyColor );
+ var ground = new Color( groundColor );
+
+ /* cough */
+ sky = new Vector3( sky.r, sky.g, sky.b );
+ ground = new Vector3( ground.r, ground.g, ground.b );
+
+ // without extra factor of PI in the shader, should = 1 / Math.sqrt( Math.PI );
+ var c0 = Math.sqrt( Math.PI );
+ var c1 = c0 * Math.sqrt( 0.75 );
+
+ this.sh.zero();
+
+ this.sh.coefficients[ 0 ].copy( sky ).add( ground ).multiplyScalar( c0 );
+ this.sh.coefficients[ 1 ].copy( sky ).sub( ground ).multiplyScalar( c1 );
+
+ },
+
// https://www.ppsloan.org/publications/StupidSH36.pdf
setFromCubeTexture: function ( cubeTexture ) {
| false |
Other | mrdoob | three.js | 1c3eefb65f6b7b1b13e306351530409149bcc206.json | Fix a bug | examples/js/exporters/GLTFExporter.js | @@ -1251,7 +1251,7 @@ THREE.GLTFExporter.prototype = {
if ( accessor !== null ) {
attributes[ attributeName ] = accessor;
- setAttributeCache( attribute, accessor );
+ setAttributeCache( accessor, attribute );
}
@@ -1339,7 +1339,7 @@ THREE.GLTFExporter.prototype = {
}
target[ gltfAttributeName ] = processAccessor( relativeAttribute, geometry );
- setAttributeCache( baseAttribute, target[ gltfAttributeName ] );
+ setAttributeCache( target[ gltfAttributeName ], baseAttribute );
}
| false |
Other | mrdoob | three.js | 0ea77c013a3e7cf645a310c584318c15945d8d17.json | Update bevelSize docs. | docs/api/en/geometries/ExtrudeBufferGeometry.html | @@ -75,7 +75,7 @@ <h3>[name]([param:Array shapes], [param:Object options])</h3>
<li>depth — float. Depth to extrude the shape. Default is 100.</li>
<li>bevelEnabled — bool. Apply beveling to the shape. Default is true.</li>
<li>bevelThickness — float. How deep into the original shape the bevel goes. Default is 6.</li>
- <li>bevelSize — float. Distance from the shape outline that the bevel extends. Default is bevelThickness - 2.</li>
+ <li>bevelSize — float. Distance from the shape outline that the bevel extends. Default is bevelThickness - 2. Negative values now do not extend the shape in the middle, but shrink it at the front and back.</li>
<li>bevelSegments — int. Number of bevel layers. Default is 3.</li>
<li>extrudePath — THREE.CurvePath. A 3D spline path along which the shape should be extruded.</li>
<li>UVGenerator — Object. object that provides UV generator functions</li> | true |
Other | mrdoob | three.js | 0ea77c013a3e7cf645a310c584318c15945d8d17.json | Update bevelSize docs. | docs/api/en/geometries/ExtrudeGeometry.html | @@ -75,7 +75,7 @@ <h3>[name]([param:Array shapes], [param:Object options])</h3>
<li>depth — float. Depth to extrude the shape. Default is 100.</li>
<li>bevelEnabled — bool. Apply beveling to the shape. Default is true.</li>
<li>bevelThickness — float. How deep into the original shape the bevel goes. Default is 6.</li>
- <li>bevelSize — float. Distance from the shape outline that the bevel extends. Default is bevelThickness - 2.</li>
+ <li>bevelSize — float. Distance from the shape outline that the bevel extends. Default is bevelThickness - 2. Negative values now do not extend the shape in the middle, but shrink it at the front and back.</li>
<li>bevelSegments — int. Number of bevel layers. Default is 3.</li>
<li>extrudePath — THREE.CurvePath. A 3D spline path along which the shape should be extruded.</li>
<li>UVGenerator — Object. object that provides UV generator functions</li> | true |
Other | mrdoob | three.js | 0ea77c013a3e7cf645a310c584318c15945d8d17.json | Update bevelSize docs. | docs/api/en/geometries/TextBufferGeometry.html | @@ -73,7 +73,7 @@ <h3>[name]([param:String text], [param:Object parameters])</h3>
<li>curveSegments — Integer. Number of points on the curves. Default is 12.</li>
<li>bevelEnabled — Boolean. Turn on bevel. Default is False.</li>
<li>bevelThickness — Float. How deep into text bevel goes. Default is 10.</li>
- <li>bevelSize — Float. How far from text outline is bevel. Default is 8.</li>
+ <li>bevelSize — Float. How far from text outline is bevel. Default is 8. Negative values now do not extend the text outline in the middle, but shrink it at the front and back.</li>
<li>bevelSegments — Integer. Number of bevel segments. Default is 3.</li>
</ul>
</p> | true |
Other | mrdoob | three.js | 0ea77c013a3e7cf645a310c584318c15945d8d17.json | Update bevelSize docs. | docs/api/en/geometries/TextGeometry.html | @@ -73,7 +73,7 @@ <h3>[name]([param:String text], [param:Object parameters])</h3>
<li>curveSegments — Integer. Number of points on the curves. Default is 12.</li>
<li>bevelEnabled — Boolean. Turn on bevel. Default is False.</li>
<li>bevelThickness — Float. How deep into text bevel goes. Default is 10.</li>
- <li>bevelSize — Float. How far from text outline is bevel. Default is 8.</li>
+ <li>bevelSize — Float. How far from text outline is bevel. Default is 8. Negative values now do not extend the text outline in the middle, but shrink it at the front and back.</li>
<li>bevelSegments — Integer. Number of bevel segments. Default is 3.</li>
</ul>
</p> | true |
Other | mrdoob | three.js | 571ce5798c7b6156a2497a5621b54ec93a29e3e4.json | Update LOD documents | docs/api/en/objects/LOD.html | @@ -72,7 +72,7 @@ <h3>[property:array levels]</h3>
<h2>Methods</h2>
<p>See the base [page:Object3D] class for common methods.</p>
- <h3>[method:LOD addLevel]( [param:Object3D object], [param:Float distance] )</h3>
+ <h3>[method:this addLevel]( [param:Object3D object], [param:Float distance] )</h3>
<p>
[page:Object3D object] - The [page:Object3D] to display at this level.<br />
[page:Float distance] - The distance at which to display this level of detail.<br /><br /> | true |
Other | mrdoob | three.js | 571ce5798c7b6156a2497a5621b54ec93a29e3e4.json | Update LOD documents | docs/api/zh/objects/LOD.html | @@ -69,7 +69,7 @@ <h3>[property:array levels]</h3>
<h2>方法</h2>
<p>请参阅其基类[page:Object3D]来查看共有方法。</p>
- <h3>[method:LOD addLevel]( [param:Object3D object], [param:Float distance] )</h3>
+ <h3>[method:this addLevel]( [param:Object3D object], [param:Float distance] )</h3>
<p>
[page:Object3D object] —— 在这个层次中将要显示的[page:Object3D]。<br />
[page:Float distance] —— 将显示这一细节层次的距离。<br /><br /> | true |
Other | mrdoob | three.js | d139bb914e9c38f7255128b40610b5ae6ff43a75.json | Update LOD documents | docs/api/en/objects/LOD.html | @@ -43,13 +43,6 @@ <h2>Example</h2>
scene.add( lod );
</code>
- <p>
- Note that for the LOD to switch between the different detail levels, you will
- have to call [page:.update update]( camera ) in your render loop. See the source code
- for this example for details:
- [example:webgl_lod WebGL / LOD]
- </div>
-
<h2>Constructor</h2>
<h3>[name]( )</h3>
<p>
@@ -60,6 +53,13 @@ <h3>[name]( )</h3>
<h2>Properties</h2>
<p>See the base [page:Object3D] class for common properties.</p>
+ <h3>[property:boolean autoUpdate]</h3>
+ <p>
+ Default is true. If set, then the renderer calls [page:.update] every frame.
+ When it isn't, then you have to manually call by yourself in the render loop
+ for levels of detail to be updated dynamically.
+ </p>
+
<h3>[property:array levels]</h3>
<p>
An array of [page:object level] objects<br /><br />
@@ -108,8 +108,7 @@ <h3>[method:null toJSON]( meta )</h3>
<h3>[method:null update]( [param:Camera camera] )</h3>
<p>
Set the visibility of each [page:levels level]'s [page:Object3D object] based on
- distance from the [page:Camera camera]. This needs to be called in the render loop
- for levels of detail to be updated dynamically.
+ distance from the [page:Camera camera].
</p>
<h2>Source</h2> | true |
Other | mrdoob | three.js | d139bb914e9c38f7255128b40610b5ae6ff43a75.json | Update LOD documents | docs/api/zh/objects/LOD.html | @@ -41,12 +41,6 @@ <h2>示例</h2>
scene.add( lod );
</code>
- <p>
- 请注意,要使得LOD在各不同细节层次之间进行切换,你将需要在你的渲染循环中调用[page:.update update]( camera )。
- 详情请查看这个示例中的源代码:
- [example:webgl_lod WebGL / LOD]
- </div>
-
<h2>Constructor</h2>
<h3>[name]( )</h3>
<p>
@@ -57,6 +51,13 @@ <h3>[name]( )</h3>
<h2>属性</h2>
<p>请参阅其基类[page:Object3D]来查看公共属性。</p>
+ <h3>[property:boolean autoUpdate]</h3>
+ <p>
+ Default is true. If set, then the renderer calls [page:.update] every frame.
+ When it isn't, then you have to manually call by yourself in the render loop
+ for levels of detail to be updated dynamically.
+ </p>
+
<h3>[property:array levels]</h3>
<p>
一个包含有[page:object level] objects(各层次物体)的数组。<br /><br />
@@ -104,7 +105,6 @@ <h3>[method:null toJSON]( meta )</h3>
<h3>[method:null update]( [param:Camera camera] )</h3>
<p>
基于每个[page:levels level]中的[page:Object3D object]和[page:Camera camera](摄像机)之间的距离,来设置其可见性。
- 为了使得多细节层次能够被自动地更新,这个方法需要在渲染循环中被调用。
</p>
<h2>源代码</h2> | true |
Other | mrdoob | three.js | 800880a22baf2599450b9d806e2d95d08f256791.json | Update LOD document | docs/api/en/objects/LOD.html | @@ -72,7 +72,7 @@ <h3>[property:array levels]</h3>
<h2>Methods</h2>
<p>See the base [page:Object3D] class for common methods.</p>
- <h3>[method:null addLevel]( [param:Object3D object], [param:Float distance] )</h3>
+ <h3>[method:LOD addLevel]( [param:Object3D object], [param:Float distance] )</h3>
<p>
[page:Object3D object] - The [page:Object3D] to display at this level.<br />
[page:Float distance] - The distance at which to display this level of detail.<br /><br /> | true |
Other | mrdoob | three.js | 800880a22baf2599450b9d806e2d95d08f256791.json | Update LOD document | docs/api/zh/objects/LOD.html | @@ -69,7 +69,7 @@ <h3>[property:array levels]</h3>
<h2>方法</h2>
<p>请参阅其基类[page:Object3D]来查看共有方法。</p>
- <h3>[method:null addLevel]( [param:Object3D object], [param:Float distance] )</h3>
+ <h3>[method:LOD addLevel]( [param:Object3D object], [param:Float distance] )</h3>
<p>
[page:Object3D object] —— 在这个层次中将要显示的[page:Object3D]。<br />
[page:Float distance] —— 将显示这一细节层次的距离。<br /><br /> | true |
Other | mrdoob | three.js | 0122d2545531626532a829a693df067e3c391e15.json | Remove `subobjectLoad` function, add comments | examples/js/loaders/LDrawLoader.js | @@ -475,7 +475,15 @@ THREE.LDrawLoader = ( function () {
subobject.url = subobjectURL;
// Load the subobject
- subobjectLoad( subobjectURL, onSubobjectLoaded, undefined, onSubobjectError, subobject );
+ // Use another file loader here so we can keep track of the subobject information
+ // and use it when processing the next model.
+ var fileLoader = new THREE.FileLoader( scope.manager );
+ fileLoader.setPath( scope.path );
+ fileLoader.load( subobjectURL, function ( text ) {
+
+ processObject( text, onSubobjectLoaded, subobject );
+
+ }, undefined, onSubobjectError );
}
@@ -1162,6 +1170,7 @@ THREE.LDrawLoader = ( function () {
case 'BFC':
+ // Changes to the backface culling state
while ( ! lp.isAtTheEnd() ) {
var token = lp.getToken();
@@ -1265,6 +1274,8 @@ THREE.LDrawLoader = ( function () {
}
+ // If the scale of the object is negated then the triangle winding order
+ // needs to be flipped.
if ( scope.separateObjects === false && matrix.determinant() < 0 ) {
bfcInverted = ! bfcInverted; | false |
Other | mrdoob | three.js | 97c9defb42634425cfa5e5795b846c62f9a784c2.json | Update code style | editor/js/Menubar.Add.js | @@ -391,15 +391,17 @@ Menubar.Add = function ( editor ) {
// OrthographicCamera
var option = new UI.Row();
- option.setClass('option');
- option.setTextContent(strings.getKey('menubar/add/orthographiccamera'));
- option.onClick(function(){
+ option.setClass( 'option' );
+ option.setTextContent( strings.getKey( 'menubar/add/orthographiccamera' ) );
+ option.onClick( function () {
+
var camera = new THREE.OrthographicCamera();
camera.name = 'OrthographicCamera';
- editor.execute(new AddObjectCommand(camera));
- });
- options.add(option);
+ editor.execute( new AddObjectCommand( camera ) );
+
+ } );
+ options.add( option );
return container;
| true |
Other | mrdoob | three.js | 97c9defb42634425cfa5e5795b846c62f9a784c2.json | Update code style | editor/js/Sidebar.Object.js | @@ -149,42 +149,42 @@ Sidebar.Object = function ( editor ) {
// left
var objectLeftRow = new UI.Row();
- var objectLeft = new UI.Number().onChange(update);
+ var objectLeft = new UI.Number().onChange( update );
- objectLeftRow.add(new UI.Text(strings.getKey('sidebar/object/left')).setWidth('90px'));
- objectLeftRow.add(objectLeft);
+ objectLeftRow.add( new UI.Text( strings.getKey( 'sidebar/object/left' ) ).setWidth( '90px' ) );
+ objectLeftRow.add( objectLeft );
- container.add(objectLeftRow);
+ container.add( objectLeftRow );
// right
-
+
var objectRightRow = new UI.Row();
- var objectRight = new UI.Number().onChange(update);
+ var objectRight = new UI.Number().onChange( update );
- objectRightRow.add(new UI.Text(strings.getKey('sidebar/object/right')).setWidth('90px'));
- objectRightRow.add(objectRight);
+ objectRightRow.add( new UI.Text( strings.getKey( 'sidebar/object/right' ) ).setWidth( '90px' ) );
+ objectRightRow.add( objectRight );
- container.add(objectRightRow);
+ container.add( objectRightRow );
// top
-
+
var objectTopRow = new UI.Row();
- var objectTop = new UI.Number().onChange(update);
+ var objectTop = new UI.Number().onChange( update );
- objectTopRow.add(new UI.Text(strings.getKey('sidebar/object/top')).setWidth('90px'));
- objectTopRow.add(objectTop);
+ objectTopRow.add( new UI.Text( strings.getKey( 'sidebar/object/top' ) ).setWidth( '90px' ) );
+ objectTopRow.add( objectTop );
- container.add(objectTopRow);
+ container.add( objectTopRow );
// bottom
-
+
var objectBottomRow = new UI.Row();
- var objectBottom = new UI.Number().onChange(update);
+ var objectBottom = new UI.Number().onChange( update );
- objectBottomRow.add(new UI.Text(strings.getKey('sidebar/object/bottom')).setWidth('90px'));
- objectBottomRow.add(objectBottom);
+ objectBottomRow.add( new UI.Text( strings.getKey( 'sidebar/object/bottom' ) ).setWidth( '90px' ) );
+ objectBottomRow.add( objectBottom );
- container.add(objectBottomRow);
+ container.add( objectBottomRow );
// near
@@ -471,18 +471,23 @@ Sidebar.Object = function ( editor ) {
if ( object.near !== undefined && Math.abs( object.near - objectNear.getValue() ) >= 0.01 ) {
editor.execute( new SetValueCommand( object, 'near', objectNear.getValue() ) );
- if(object.isOrthographicCamera){
+ if ( object.isOrthographicCamera ) {
+
object.updateProjectionMatrix();
+
}
}
if ( object.far !== undefined && Math.abs( object.far - objectFar.getValue() ) >= 0.01 ) {
editor.execute( new SetValueCommand( object, 'far', objectFar.getValue() ) );
- if(object.isOrthographicCamera){
+ if ( object.isOrthographicCamera ) {
+
object.updateProjectionMatrix();
+
}
+
}
if ( object.intensity !== undefined && Math.abs( object.intensity - objectIntensity.getValue() ) >= 0.01 ) {
@@ -600,12 +605,12 @@ Sidebar.Object = function ( editor ) {
'intensity': objectIntensityRow,
'color': objectColorRow,
'groundColor': objectGroundColorRow,
- 'distance' : objectDistanceRow,
- 'angle' : objectAngleRow,
- 'penumbra' : objectPenumbraRow,
- 'decay' : objectDecayRow,
- 'castShadow' : objectShadowRow,
- 'receiveShadow' : objectReceiveShadow,
+ 'distance': objectDistanceRow,
+ 'angle': objectAngleRow,
+ 'penumbra': objectPenumbraRow,
+ 'decay': objectDecayRow,
+ 'castShadow': objectShadowRow,
+ 'receiveShadow': objectReceiveShadow,
'shadow': objectShadowRadius
};
| true |
Other | mrdoob | three.js | 97c9defb42634425cfa5e5795b846c62f9a784c2.json | Update code style | editor/js/Viewport.js | @@ -503,12 +503,15 @@ var Viewport = function ( editor ) {
signals.viewportCameraChanged.add( function ( viewportCamera ) {
- if(viewportCamera.isPerspectiveCamera) {
+ if ( viewportCamera.isPerspectiveCamera ) {
+
viewportCamera.aspect = editor.camera.aspect;
viewportCamera.projectionMatrix.copy( editor.camera.projectionMatrix );
- }
- else if(!viewportCamera.isOrthographicCamera){
+
+ } else if ( ! viewportCamera.isOrthographicCamera ) {
+
throw "Invalid camera set as viewport";
+
}
camera = viewportCamera; | true |
Other | mrdoob | three.js | d1c244492a18bb8e0bbe3ca3343a0688df66f9f0.json | Remove redundant renormalization and add comment | examples/js/animation/MMDPhysics.js | @@ -1046,11 +1046,15 @@ THREE.MMDPhysics = ( function () {
thQ.set( q.x(), q.y(), q.z(), q.w() );
thQ2.setFromRotationMatrix( this.bone.matrixWorld );
thQ2.conjugate();
- thQ2.multiply( thQ ).normalize();
+ thQ2.multiply( thQ );
//this.bone.quaternion.multiply( thQ2 );
thQ3.setFromRotationMatrix( this.bone.matrix );
+
+ // Renormalizing quaternion here because repeatedly transforming
+ // quaternion continuously accumulates floating point error and
+ // can end up being overflow. See #15335
this.bone.quaternion.copy( thQ2.multiply( thQ3 ).normalize() );
manager.freeThreeQuaternion( thQ ); | false |
Other | mrdoob | three.js | 3d06bc0f2191750e6f401b54dedcd044225a8c87.json | Update webgl_lod example | examples/webgl_lod.html | @@ -74,7 +74,6 @@
scene = new THREE.Scene();
scene.fog = new THREE.Fog( 0x000000, 1, 15000 );
- scene.autoUpdate = false;
var light = new THREE.PointLight( 0xff2200 );
light.position.set( 0, 0, 0 );
@@ -153,17 +152,6 @@
controls.update( clock.getDelta() );
- scene.updateMatrixWorld();
- scene.traverse( function ( object ) {
-
- if ( object instanceof THREE.LOD ) {
-
- object.update( camera );
-
- }
-
- } );
-
renderer.render( scene, camera );
} | false |
Other | mrdoob | three.js | 9c0b8a57be4464b30f420357af2cd9308fda0442.json | Add .autoUpdate to LOD | src/objects/LOD.js | @@ -20,6 +20,8 @@ function LOD() {
}
} );
+ this.autoUpdate = true;
+
}
LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { | true |
Other | mrdoob | three.js | 9c0b8a57be4464b30f420357af2cd9308fda0442.json | Add .autoUpdate to LOD | src/renderers/WebGLRenderer.js | @@ -1244,6 +1244,10 @@ function WebGLRenderer( parameters ) {
groupOrder = object.renderOrder;
+ } else if ( object.isLOD ) {
+
+ if ( object.autoUpdate ) object.update( camera );
+
} else if ( object.isLight ) {
currentRenderState.pushLight( object ); | true |
Other | mrdoob | three.js | 14d58824ea8973d4200e7c021623024ac7252a9b.json | Add missing LOD.isLOD | src/objects/LOD.js | @@ -26,6 +26,8 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
constructor: LOD,
+ isLOD: true,
+
copy: function ( source ) {
Object3D.prototype.copy.call( this, source, false ); | false |
Other | mrdoob | three.js | e2b702c13ccd1acb1539123f369913d45164df7d.json | Add gl_Position as a keyword | editor/js/libs/codemirror/mode/glsl.js | @@ -205,7 +205,7 @@
"do for while if else in out inout float int void bool true false " +
"lowp mediump highp precision invariant discard return mat2 mat3 " +
"mat4 vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 sampler2D " +
- "samplerCube struct gl_FragCoord gl_FragColor";
+ "samplerCube struct gl_FragCoord gl_FragColor gl_Position";
var glslBuiltins = "radians degrees sin cos tan asin acos atan pow " +
"exp log exp2 log2 sqrt inversesqrt abs sign floor ceil fract mod " +
"min max clamp mix step smoothstep length distance dot cross " + | false |
Other | mrdoob | three.js | 74c27264d7582b0b481d44e3cc673be73110db98.json | Add double side support | examples/js/loaders/LDrawLoader.js | @@ -1046,9 +1046,10 @@ THREE.LDrawLoader = ( function () {
}
- var bfcEnabled = false;
+ var bfcCertified = false;
var bfcCCW = true;
var bfcInverted = false;
+ var bfcCull = true;
// Parse all line commands
for ( lineIndex = 0; lineIndex < numLines; lineIndex ++ ) {
@@ -1152,7 +1153,7 @@ THREE.LDrawLoader = ( function () {
currentEmbeddedFileName = lp.getRemainingString();
currentEmbeddedText = '';
- bfcEnabled = false;
+ bfcCertified = false;
bfcCCW = true;
}
@@ -1170,7 +1171,7 @@ THREE.LDrawLoader = ( function () {
case 'CERTIFY':
case 'NOCERTIFY':
- bfcEnabled = token === 'CERTIFY';
+ bfcCertified = token === 'CERTIFY';
bfcCCW = true;
break;
@@ -1191,7 +1192,7 @@ THREE.LDrawLoader = ( function () {
case 'CLIP':
case 'NOCLIP':
- console.warn( 'THREE.LDrawLoader: BFC CLIP and NOCLIP directives ignored.' );
+ bfcCull = token === 'CLIP';
break;
@@ -1305,7 +1306,8 @@ THREE.LDrawLoader = ( function () {
var material = parseColourCode( lp );
var inverted = currentParseScope.inverted;
- var ccw = ! bfcEnabled || ( bfcCCW !== inverted );
+ var ccw = bfcCCW !== inverted;
+ var doubleSided = ! bfcCertified || ! bfcCull;
var v0, v1, v2;
if ( ccw === true ) {
@@ -1330,6 +1332,18 @@ THREE.LDrawLoader = ( function () {
v2: v2
} );
+ if ( doubleSided === true ) {
+
+ triangles.push( {
+ material: material,
+ colourCode: material.userData.code,
+ v0: v0,
+ v1: v2,
+ v2: v1
+ } );
+
+ }
+
break;
// Line type 4: Quadrilateral
@@ -1338,7 +1352,8 @@ THREE.LDrawLoader = ( function () {
var material = parseColourCode( lp );
var inverted = currentParseScope.inverted;
- var ccw = ! bfcEnabled || ( bfcCCW !== inverted );
+ var ccw = bfcCCW !== inverted;
+ var doubleSided = ! bfcCertified || ! bfcCull;
var v0, v1, v2, v3;
if ( ccw === true ) {
@@ -1373,6 +1388,26 @@ THREE.LDrawLoader = ( function () {
v2: v3
} );
+ if ( doubleSided === true ) {
+
+ triangles.push( {
+ material: material,
+ colourCode: material.userData.code,
+ v0: v0,
+ v1: v2,
+ v2: v1
+ } );
+
+ triangles.push( {
+ material: material,
+ colourCode: material.userData.code,
+ v0: v0,
+ v1: v3,
+ v2: v2
+ } );
+
+ }
+
break;
// Line type 5: Optional line | false |
Other | mrdoob | three.js | 7d2e5be900680cede5ac76f8e12f3510a22c6c66.json | Add anti aliasing to the LDraw example | examples/webgl_loader_ldraw.html | @@ -97,7 +97,7 @@
//
- renderer = new THREE.WebGLRenderer();
+ renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement ); | false |
Other | mrdoob | three.js | 16d17ab3230c7358e771c1a50932ac3a4d5cb7be.json | Update code style | editor/js/Sidebar.Geometry.LatheGeometry.js | @@ -2,7 +2,7 @@
* @author rfm1201
*/
-Sidebar.Geometry.LatheGeometry = function( editor, object ) {
+Sidebar.Geometry.LatheGeometry = function ( editor, object ) {
var strings = editor.strings;
@@ -48,8 +48,8 @@ Sidebar.Geometry.LatheGeometry = function( editor, object ) {
var pointsRow = new UI.Row();
pointsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/lathe_geometry/points' ) ).setWidth( '90px' ) );
- var points = new UI.Points2().setValue(parameters.points).onChange(update);
- pointsRow.add(points);
+ var points = new UI.Points2().setValue( parameters.points ).onChange( update );
+ pointsRow.add( points );
container.add( pointsRow );
| true |
Other | mrdoob | three.js | 16d17ab3230c7358e771c1a50932ac3a4d5cb7be.json | Update code style | editor/js/Sidebar.Geometry.TubeGeometry.js | @@ -18,8 +18,8 @@ Sidebar.Geometry.TubeGeometry = function ( editor, object ) {
var pointsRow = new UI.Row();
pointsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/tube_geometry/path' ) ).setWidth( '90px' ) );
- var points = new UI.Points3().setValue(parameters.path.points).onChange(update);
- pointsRow.add(points);
+ var points = new UI.Points3().setValue( parameters.path.points ).onChange( update );
+ pointsRow.add( points );
container.add( pointsRow );
| true |
Other | mrdoob | three.js | 16d17ab3230c7358e771c1a50932ac3a4d5cb7be.json | Update code style | editor/js/libs/ui.three.js | @@ -75,7 +75,7 @@ UI.Texture = function ( mapping ) {
reader.addEventListener( 'load', function ( event ) {
var image = document.createElement( 'img' );
- image.addEventListener( 'load', function( event ) {
+ image.addEventListener( 'load', function ( event ) {
var texture = new THREE.Texture( this, mapping );
texture.sourceFile = file.name;
@@ -188,11 +188,13 @@ UI.Outliner = function ( editor ) {
dom.addEventListener( 'keydown', function ( event ) {
switch ( event.keyCode ) {
+
case 38: // up
case 40: // down
event.preventDefault();
event.stopPropagation();
break;
+
}
}, false );
@@ -201,12 +203,14 @@ UI.Outliner = function ( editor ) {
dom.addEventListener( 'keyup', function ( event ) {
switch ( event.keyCode ) {
+
case 38: // up
scope.selectIndex( scope.selectedIndex - 1 );
break;
case 40: // down
scope.selectIndex( scope.selectedIndex + 1 );
break;
+
}
}, false );
@@ -459,7 +463,7 @@ var Points = function ( onAddClicked ) {
}
- }.bind(this);
+ }.bind( this );
this.dom = span.dom;
this.pointsUI = [];
@@ -511,11 +515,13 @@ Points.prototype.deletePointRow = function ( idx, dontUpdate ) {
};
-UI.Points2 = function(){
- Points.call( this, UI.Points2.addRow.bind(this));
+UI.Points2 = function () {
+
+ Points.call( this, UI.Points2.addRow.bind( this ) );
return this;
-}
+
+};
UI.Points2.prototype = Object.create( Points.prototype );
UI.Points2.prototype.constructor = UI.Points2;
@@ -536,9 +542,10 @@ UI.Points2.addRow = function () {
this.update();
-}
+};
UI.Points2.prototype.getValue = function () {
+
var points = [];
var count = 0;
@@ -555,7 +562,8 @@ UI.Points2.prototype.getValue = function () {
}
return points;
-}
+
+};
UI.Points2.prototype.setValue = function ( points ) {
@@ -589,19 +597,21 @@ UI.Points2.prototype.createPointRow = function ( x, y ) {
} );
- this.pointsUI.push( { row: pointRow, lbl: lbl, x: txtX, y: txtY } );
+ this.pointsUI.push( { row: pointRow, lbl: lbl, x: txtX, y: txtY } );
++ this.lastPointIdx;
pointRow.add( lbl, txtX, txtY, btn );
return pointRow;
};
-UI.Points3 = function(){
- Points.call( this, UI.Points3.addRow.bind(this));
+UI.Points3 = function () {
+
+ Points.call( this, UI.Points3.addRow.bind( this ) );
return this;
-}
+
+};
UI.Points3.prototype = Object.create( Points.prototype );
UI.Points3.prototype.constructor = UI.Points3;
@@ -622,9 +632,10 @@ UI.Points3.addRow = function () {
this.update();
-}
+};
UI.Points3.prototype.getValue = function () {
+
var points = [];
var count = 0;
@@ -641,7 +652,8 @@ UI.Points3.prototype.getValue = function () {
}
return points;
-}
+
+};
UI.Points3.prototype.setValue = function ( points ) {
@@ -676,7 +688,7 @@ UI.Points3.prototype.createPointRow = function ( x, y, z ) {
} );
- this.pointsUI.push( { row: pointRow, lbl: lbl, x: txtX, y: txtY, z : txtZ } );
+ this.pointsUI.push( { row: pointRow, lbl: lbl, x: txtX, y: txtY, z: txtZ } );
++ this.lastPointIdx;
pointRow.add( lbl, txtX, txtY, txtZ, btn );
| true |
Other | mrdoob | three.js | d9a108f65099321a80c2d4c84a6a3ff328c408df.json | Update LatheGeometry to use Points2 | editor/js/Sidebar.Geometry.LatheGeometry.js | @@ -45,99 +45,18 @@ Sidebar.Geometry.LatheGeometry = function( editor, object ) {
// points
- var lastPointIdx = 0;
- var pointsUI = [];
-
var pointsRow = new UI.Row();
pointsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/lathe_geometry/points' ) ).setWidth( '90px' ) );
- var points = new UI.Span().setDisplay( 'inline-block' );
- pointsRow.add( points );
-
- var pointsList = new UI.Div();
- points.add( pointsList );
-
- for ( var i = 0; i < parameters.points.length; i ++ ) {
-
- var point = parameters.points[ i ];
- pointsList.add( createPointRow( point.x, point.y ) );
-
- }
-
- var addPointButton = new UI.Button( '+' ).onClick( function() {
-
- if( pointsUI.length === 0 ){
-
- pointsList.add( createPointRow( 0, 0 ) );
-
- } else {
-
- var point = pointsUI[ pointsUI.length - 1 ];
-
- pointsList.add( createPointRow( point.x.getValue(), point.y.getValue() ) );
-
- }
-
- update();
-
- } );
- points.add( addPointButton );
+ var points = new UI.Points2().setValue(parameters.points).onChange(update);
+ pointsRow.add(points);
container.add( pointsRow );
- //
-
- function createPointRow( x, y ) {
-
- var pointRow = new UI.Div();
- var lbl = new UI.Text( lastPointIdx + 1 ).setWidth( '20px' );
- var txtX = new UI.Number( x ).setRange( 0, Infinity ).setWidth( '40px' ).onChange( update );
- var txtY = new UI.Number( y ).setWidth( '40px' ).onChange( update );
- var idx = lastPointIdx;
- var btn = new UI.Button( '-' ).onClick( function() {
-
- deletePointRow( idx );
-
- } );
-
- pointsUI.push( { row: pointRow, lbl: lbl, x: txtX, y: txtY } );
- lastPointIdx ++;
- pointRow.add( lbl, txtX, txtY, btn );
-
- return pointRow;
-
- }
-
- function deletePointRow( idx ) {
-
- if ( ! pointsUI[ idx ] ) return;
-
- pointsList.remove( pointsUI[ idx ].row );
- pointsUI[ idx ] = null;
-
- update();
-
- }
-
function update() {
- var points = [];
- var count = 0;
-
- for ( var i = 0; i < pointsUI.length; i ++ ) {
-
- var pointUI = pointsUI[ i ];
-
- if ( ! pointUI ) continue;
-
- points.push( new THREE.Vector2( pointUI.x.getValue(), pointUI.y.getValue() ) );
- count ++;
- pointUI.lbl.setValue( count );
-
- }
-
editor.execute( new SetGeometryCommand( object, new THREE[ geometry.type ](
- points,
+ points.getValue(),
segments.getValue(),
phiStart.getValue() / 180 * Math.PI,
phiLength.getValue() / 180 * Math.PI | false |
Other | mrdoob | three.js | 4d77551ca2d49ad7db8fd75126d565613cdd6f87.json | Add .renderOutline() to OutlineEffect | examples/js/effects/OutlineEffect.js | @@ -3,6 +3,41 @@
*
* Reference: https://en.wikipedia.org/wiki/Cel_shading
*
+ * API
+ *
+ * 1. Traditional
+ *
+ * var effect = new THREE.OutlineEffect( renderer );
+ *
+ * function render() {
+ *
+ * effect.render( scene, camera );
+ *
+ * }
+ *
+ * 2. VR compatible
+ *
+ * var effect = new THREE.OutlineEffect( renderer );
+ * var renderingOutline = false;
+ *
+ * scene.onAfterRender = function () {
+ *
+ * if ( renderingOutline ) return;
+ *
+ * renderingOutline = true;
+ *
+ * effect.renderOutline( scene, camera );
+ *
+ * renderingOutline = false;
+ *
+ * };
+ *
+ * function render() {
+ *
+ * renderer.render( scene, camera );
+ *
+ * }
+ *
* // How to set default outline parameters
* new THREE.OutlineEffect( renderer, {
* defaultThickness: 0.01,
@@ -435,10 +470,17 @@ THREE.OutlineEffect = function ( renderer, parameters ) {
var currentAutoClear = renderer.autoClear;
renderer.autoClear = this.autoClear;
- // 1. render normally
renderer.render( scene, camera );
- // 2. render outline
+ renderer.autoClear = currentAutoClear;
+
+ this.renderOutline( scene, camera );
+
+ };
+
+ this.renderOutline = function ( scene, camera ) {
+
+ var currentAutoClear = renderer.autoClear;
var currentSceneAutoUpdate = scene.autoUpdate;
var currentSceneBackground = scene.background;
var currentShadowMapEnabled = renderer.shadowMap.enabled; | false |
Other | mrdoob | three.js | e13d5287dba54c05121f3a4a3a808a40fa51c11a.json | Add point light to camera | examples/webgl_geometry_colors_lookuptable.html | @@ -79,6 +79,7 @@
perpCamera = new THREE.PerspectiveCamera( 60, width / height, 1, 100 );
perpCamera.position.set( 0, 0, 10 );
+ scene.add(perpCamera);
verticalLegendGroup = new THREE.Group();
horizontalLegendGroup = new THREE.Group();
@@ -89,9 +90,6 @@
orthoCamera = new THREE.OrthographicCamera( - 6, 6, 2, - 2, 1, 10 );
orthoCamera.position.set( 3, 0, 10 );
- var ambientLight = new THREE.AmbientLight( 0x444444 );
- scene.add( ambientLight );
-
mesh = new THREE.Mesh( undefined, new THREE.MeshLambertMaterial( {
side: THREE.DoubleSide,
color: 0xF5F5F5,
@@ -107,14 +105,14 @@
};
loadModel( );
- var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.7 );
- directionalLight.position.set( 17, 9, 30 );
- scene.add( directionalLight );
+ var pointLight = new THREE.PointLight( 0xffffff, 1 );
+ pointLight.position.set( 17, 9, 30 );
+ perpCamera.add( pointLight );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.autoClear = false;
renderer.setPixelRatio( window.devicePixelRatio );
- renderer.setSize( window.innerWidth, window.innerHeight );
+ renderer.setSize( width, height );
container.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize, false ); | false |
Other | mrdoob | three.js | e4e8ed68bcf6595eb7b7c4e2a41be47ff83dffbb.json | Update code style | examples/js/math/Lut.js | @@ -5,7 +5,7 @@
THREE.Lut = function ( colormap, numberofcolors ) {
this.lut = [];
- this.setColorMap(colormap, numberofcolors);
+ this.setColorMap( colormap, numberofcolors );
return this;
};
@@ -64,37 +64,39 @@ THREE.Lut.prototype = {
},
- setColorMap: function(colormap, numberofcolors){
+ setColorMap: function ( colormap, numberofcolors ) {
+
this.map = THREE.ColorMapKeywords[ colormap ] || THREE.ColorMapKeywords.rainbow;
this.n = numberofcolors || 32;
this.mapname = colormap;
-
+
var step = 1.0 / this.n;
-
+
this.lut.length = 0;
for ( var i = 0; i <= 1; i += step ) {
-
+
for ( var j = 0; j < this.map.length - 1; j ++ ) {
-
+
if ( i >= this.map[ j ][ 0 ] && i < this.map[ j + 1 ][ 0 ] ) {
-
+
var min = this.map[ j ][ 0 ];
var max = this.map[ j + 1 ][ 0 ];
-
+
var minColor = new THREE.Color( this.map[ j ][ 1 ] );
var maxColor = new THREE.Color( this.map[ j + 1 ][ 1 ] );
-
+
var color = minColor.lerp( maxColor, ( i - min ) / ( max - min ) );
-
+
this.lut.push( color );
-
+
}
-
+
}
-
+
}
return this;
+
},
copy: function ( lut ) {
@@ -137,23 +139,25 @@ THREE.Lut.prototype = {
},
- createCanvas: function(){
+ createCanvas: function () {
+
var canvas = document.createElement( 'canvas' );
canvas.setAttribute( 'width', 1 );
canvas.setAttribute( 'height', this.n );
canvas.setAttribute( 'id', 'legend' );
canvas.setAttribute( 'hidden', true );
- this.updateCanvas(canvas);
+ this.updateCanvas( canvas );
return canvas;
+
},
- updateCanvas: function(canvas){
+ updateCanvas: function ( canvas ) {
canvas = canvas || this.legend.canvas;
- var ctx = canvas.getContext('2d', {alpha : false});
+ var ctx = canvas.getContext( '2d', { alpha: false } );
var imageData = ctx.getImageData( 0, 0, 1, this.n );
@@ -195,6 +199,7 @@ THREE.Lut.prototype = {
ctx.putImageData( imageData, 0, 0 );
return canvas;
+
},
setLegendOn: function ( parameters ) { | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.