提交 15941e89 编写于 作者: M Mr.doob 提交者: GitHub

Merge branch 'dev' into feat-gltf2-binary

......@@ -15514,43 +15514,46 @@
}
Camera.prototype = Object.create( Object3D.prototype );
Camera.prototype.constructor = Camera;
Camera.prototype = Object.assign( Object.create( Object3D.prototype ), {
Camera.prototype.isCamera = true;
constructor: Camera,
Camera.prototype.getWorldDirection = function () {
isCamera: true,
var quaternion = new Quaternion();
copy: function ( source ) {
return function getWorldDirection( optionalTarget ) {
Object3D.prototype.copy.call( this, source );
var result = optionalTarget || new Vector3();
this.matrixWorldInverse.copy( source.matrixWorldInverse );
this.projectionMatrix.copy( source.projectionMatrix );
this.getWorldQuaternion( quaternion );
return this;
return result.set( 0, 0, - 1 ).applyQuaternion( quaternion );
},
};
getWorldDirection: function () {
}();
var quaternion = new Quaternion();
return function getWorldDirection( optionalTarget ) {
Camera.prototype.clone = function () {
var result = optionalTarget || new Vector3();
this.getWorldQuaternion( quaternion );
return new this.constructor().copy( this );
return result.set( 0, 0, - 1 ).applyQuaternion( quaternion );
};
};
Camera.prototype.copy = function ( source ) {
}(),
Object3D.prototype.copy.call( this, source );
clone: function () {
this.matrixWorldInverse.copy( source.matrixWorldInverse );
this.projectionMatrix.copy( source.projectionMatrix );
return new this.constructor().copy( this );
return this;
}
};
} );
/**
* @author mrdoob / http://mrdoob.com/
......@@ -15711,7 +15714,7 @@
},
clearViewOffset: function() {
clearViewOffset: function () {
this.view = null;
this.updateProjectionMatrix();
......@@ -20815,6 +20818,8 @@
// update camera matrices and frustum
camera.onBeforeRender( _this );
if ( camera.parent === null ) camera.updateMatrixWorld();
camera.matrixWorldInverse.getInverse( camera.matrixWorld );
......@@ -20963,6 +20968,7 @@
// opaque pass (front-to-back order)
state.setBlending( NoBlending );
if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera );
// transparent pass (back-to-front order)
......@@ -20990,6 +20996,14 @@
state.buffers.depth.setMask( true );
state.buffers.color.setMask( true );
if ( camera.isArrayCamera && camera.enabled ) {
_this.setScissorTest( false );
}
camera.onAfterRender( _this );
// _gl.finish();
};
......@@ -21156,22 +21170,30 @@
object.onBeforeRender( _this, scene, camera, geometry, material, group );
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
if ( camera.isArrayCamera && camera.enabled ) {
if ( object.isImmediateRenderObject ) {
var cameras = camera.cameras;
state.setMaterial( material );
for ( var j = 0, jl = cameras.length; j < jl; j ++ ) {
var program = setProgram( camera, scene.fog, material, object );
var camera2 = cameras[ j ];
var bounds = camera2.bounds;
_this.setViewport(
bounds.x * _width * _pixelRatio, bounds.y * _height * _pixelRatio,
bounds.z * _width * _pixelRatio, bounds.w * _height * _pixelRatio
);
_this.setScissor(
bounds.x * _width * _pixelRatio, bounds.y * _height * _pixelRatio,
bounds.z * _width * _pixelRatio, bounds.w * _height * _pixelRatio
);
_this.setScissorTest( true );
renderObject( object, scene, camera2, geometry, material, group );
_currentGeometryProgram = '';
renderObjectImmediate( object, program, material );
}
} else {
_this.renderBufferDirect( camera, scene.fog, geometry, material, object, group );
renderObject( object, scene, camera, geometry, material, group );
}
......@@ -21181,6 +21203,29 @@
}
function renderObject( object, scene, camera, geometry, material, group ) {
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
if ( object.isImmediateRenderObject ) {
state.setMaterial( material );
var program = setProgram( camera, scene.fog, material, object );
_currentGeometryProgram = '';
renderObjectImmediate( object, program, material );
} else {
_this.renderBufferDirect( camera, scene.fog, geometry, material, object, group );
}
}
function initMaterial( material, fog, object ) {
var materialProperties = properties.get( material );
......@@ -35715,6 +35760,27 @@
CubeCamera.prototype = Object.create( Object3D.prototype );
CubeCamera.prototype.constructor = CubeCamera;
/**
* @author mrdoob / http://mrdoob.com/
*/
function ArrayCamera( array ) {
PerspectiveCamera.call( this );
this.enabled = false;
this.cameras = array || [];
}
ArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), {
constructor: ArrayCamera,
isArrayCamera: true
} );
/**
* @author mrdoob / http://mrdoob.com/
*/
......@@ -39483,6 +39549,7 @@
if ( this.autoStart && ! this.running ) {
this.start();
return 0;
}
......@@ -43110,6 +43177,7 @@
exports.PerspectiveCamera = PerspectiveCamera;
exports.OrthographicCamera = OrthographicCamera;
exports.CubeCamera = CubeCamera;
exports.ArrayCamera = ArrayCamera;
exports.Camera = Camera;
exports.AudioListener = AudioListener;
exports.PositionalAudio = PositionalAudio;
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -15508,43 +15508,46 @@ function Camera() {
}
Camera.prototype = Object.create( Object3D.prototype );
Camera.prototype.constructor = Camera;
Camera.prototype = Object.assign( Object.create( Object3D.prototype ), {
Camera.prototype.isCamera = true;
constructor: Camera,
Camera.prototype.getWorldDirection = function () {
isCamera: true,
var quaternion = new Quaternion();
copy: function ( source ) {
return function getWorldDirection( optionalTarget ) {
Object3D.prototype.copy.call( this, source );
var result = optionalTarget || new Vector3();
this.matrixWorldInverse.copy( source.matrixWorldInverse );
this.projectionMatrix.copy( source.projectionMatrix );
this.getWorldQuaternion( quaternion );
return this;
return result.set( 0, 0, - 1 ).applyQuaternion( quaternion );
},
};
getWorldDirection: function () {
}();
var quaternion = new Quaternion();
return function getWorldDirection( optionalTarget ) {
Camera.prototype.clone = function () {
var result = optionalTarget || new Vector3();
this.getWorldQuaternion( quaternion );
return new this.constructor().copy( this );
return result.set( 0, 0, - 1 ).applyQuaternion( quaternion );
};
};
Camera.prototype.copy = function ( source ) {
}(),
Object3D.prototype.copy.call( this, source );
clone: function () {
this.matrixWorldInverse.copy( source.matrixWorldInverse );
this.projectionMatrix.copy( source.projectionMatrix );
return new this.constructor().copy( this );
return this;
}
};
} );
/**
* @author mrdoob / http://mrdoob.com/
......@@ -15705,7 +15708,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
},
clearViewOffset: function() {
clearViewOffset: function () {
this.view = null;
this.updateProjectionMatrix();
......@@ -20809,6 +20812,8 @@ function WebGLRenderer( parameters ) {
// update camera matrices and frustum
camera.onBeforeRender( _this );
if ( camera.parent === null ) camera.updateMatrixWorld();
camera.matrixWorldInverse.getInverse( camera.matrixWorld );
......@@ -20957,6 +20962,7 @@ function WebGLRenderer( parameters ) {
// opaque pass (front-to-back order)
state.setBlending( NoBlending );
if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera );
// transparent pass (back-to-front order)
......@@ -20984,6 +20990,14 @@ function WebGLRenderer( parameters ) {
state.buffers.depth.setMask( true );
state.buffers.color.setMask( true );
if ( camera.isArrayCamera && camera.enabled ) {
_this.setScissorTest( false );
}
camera.onAfterRender( _this );
// _gl.finish();
};
......@@ -21150,22 +21164,30 @@ function WebGLRenderer( parameters ) {
object.onBeforeRender( _this, scene, camera, geometry, material, group );
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
if ( camera.isArrayCamera && camera.enabled ) {
if ( object.isImmediateRenderObject ) {
var cameras = camera.cameras;
state.setMaterial( material );
for ( var j = 0, jl = cameras.length; j < jl; j ++ ) {
var program = setProgram( camera, scene.fog, material, object );
var camera2 = cameras[ j ];
var bounds = camera2.bounds;
_this.setViewport(
bounds.x * _width * _pixelRatio, bounds.y * _height * _pixelRatio,
bounds.z * _width * _pixelRatio, bounds.w * _height * _pixelRatio
);
_this.setScissor(
bounds.x * _width * _pixelRatio, bounds.y * _height * _pixelRatio,
bounds.z * _width * _pixelRatio, bounds.w * _height * _pixelRatio
);
_this.setScissorTest( true );
renderObject( object, scene, camera2, geometry, material, group );
_currentGeometryProgram = '';
renderObjectImmediate( object, program, material );
}
} else {
_this.renderBufferDirect( camera, scene.fog, geometry, material, object, group );
renderObject( object, scene, camera, geometry, material, group );
}
......@@ -21175,6 +21197,29 @@ function WebGLRenderer( parameters ) {
}
function renderObject( object, scene, camera, geometry, material, group ) {
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
if ( object.isImmediateRenderObject ) {
state.setMaterial( material );
var program = setProgram( camera, scene.fog, material, object );
_currentGeometryProgram = '';
renderObjectImmediate( object, program, material );
} else {
_this.renderBufferDirect( camera, scene.fog, geometry, material, object, group );
}
}
function initMaterial( material, fog, object ) {
var materialProperties = properties.get( material );
......@@ -35709,6 +35754,27 @@ function CubeCamera( near, far, cubeResolution ) {
CubeCamera.prototype = Object.create( Object3D.prototype );
CubeCamera.prototype.constructor = CubeCamera;
/**
* @author mrdoob / http://mrdoob.com/
*/
function ArrayCamera( array ) {
PerspectiveCamera.call( this );
this.enabled = false;
this.cameras = array || [];
}
ArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), {
constructor: ArrayCamera,
isArrayCamera: true
} );
/**
* @author mrdoob / http://mrdoob.com/
*/
......@@ -39477,6 +39543,7 @@ Object.assign( Clock.prototype, {
if ( this.autoStart && ! this.running ) {
this.start();
return 0;
}
......@@ -43045,4 +43112,4 @@ function CanvasRenderer() {
}
export { WebGLRenderTargetCube, WebGLRenderTarget, WebGLRenderer, ShaderLib, UniformsLib, UniformsUtils, ShaderChunk, FogExp2, Fog, Scene, LensFlare, Sprite, LOD, SkinnedMesh, Skeleton, Bone, Mesh, LineSegments, LineLoop, Line, Points, Group, VideoTexture, DataTexture, CompressedTexture, CubeTexture, CanvasTexture, DepthTexture, Texture, CompressedTextureLoader, DataTextureLoader, CubeTextureLoader, TextureLoader, ObjectLoader, MaterialLoader, BufferGeometryLoader, DefaultLoadingManager, LoadingManager, JSONLoader, ImageLoader, FontLoader, FileLoader, Loader, Cache, AudioLoader, SpotLightShadow, SpotLight, PointLight, RectAreaLight, HemisphereLight, DirectionalLightShadow, DirectionalLight, AmbientLight, LightShadow, Light, StereoCamera, PerspectiveCamera, OrthographicCamera, CubeCamera, Camera, AudioListener, PositionalAudio, AudioContext, AudioAnalyser, Audio, VectorKeyframeTrack, StringKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, ColorKeyframeTrack, BooleanKeyframeTrack, PropertyMixer, PropertyBinding, KeyframeTrack, AnimationUtils, AnimationObjectGroup, AnimationMixer, AnimationClip, Uniform, InstancedBufferGeometry, BufferGeometry, GeometryIdCount, Geometry, InterleavedBufferAttribute, InstancedInterleavedBuffer, InterleavedBuffer, InstancedBufferAttribute, Face3, Object3D, Raycaster, Layers, EventDispatcher, Clock, QuaternionLinearInterpolant, LinearInterpolant, DiscreteInterpolant, CubicInterpolant, Interpolant, Triangle, _Math as Math, Spherical, Cylindrical, Plane, Frustum, Sphere, Ray, Matrix4, Matrix3, Box3, Box2, Line3, Euler, Vector4, Vector3, Vector2, Quaternion, Color, MorphBlendMesh, ImmediateRenderObject, VertexNormalsHelper, SpotLightHelper, SkeletonHelper, PointLightHelper, RectAreaLightHelper, HemisphereLightHelper, GridHelper, PolarGridHelper, FaceNormalsHelper, DirectionalLightHelper, CameraHelper, BoxHelper, ArrowHelper, AxisHelper, CatmullRomCurve3, CubicBezierCurve3, QuadraticBezierCurve3, LineCurve3, ArcCurve, EllipseCurve, SplineCurve, CubicBezierCurve, QuadraticBezierCurve, LineCurve, Shape, Path, ShapePath, Font, CurvePath, Curve, ShapeUtils, SceneUtils, WireframeGeometry, ParametricGeometry, ParametricBufferGeometry, TetrahedronGeometry, TetrahedronBufferGeometry, OctahedronGeometry, OctahedronBufferGeometry, IcosahedronGeometry, IcosahedronBufferGeometry, DodecahedronGeometry, DodecahedronBufferGeometry, PolyhedronGeometry, PolyhedronBufferGeometry, TubeGeometry, TubeBufferGeometry, TorusKnotGeometry, TorusKnotBufferGeometry, TorusGeometry, TorusBufferGeometry, TextGeometry, TextBufferGeometry, SphereGeometry, SphereBufferGeometry, RingGeometry, RingBufferGeometry, PlaneGeometry, PlaneBufferGeometry, LatheGeometry, LatheBufferGeometry, ShapeGeometry, ShapeBufferGeometry, ExtrudeGeometry, ExtrudeBufferGeometry, EdgesGeometry, ConeGeometry, ConeBufferGeometry, CylinderGeometry, CylinderBufferGeometry, CircleGeometry, CircleBufferGeometry, BoxGeometry, BoxBufferGeometry, ShadowMaterial, SpriteMaterial, RawShaderMaterial, ShaderMaterial, PointsMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshPhongMaterial, MeshToonMaterial, MeshNormalMaterial, MeshLambertMaterial, MeshDepthMaterial, MeshBasicMaterial, LineDashedMaterial, LineBasicMaterial, Material, Float64BufferAttribute, Float32BufferAttribute, Uint32BufferAttribute, Int32BufferAttribute, Uint16BufferAttribute, Int16BufferAttribute, Uint8ClampedBufferAttribute, Uint8BufferAttribute, Int8BufferAttribute, BufferAttribute, REVISION, MOUSE, CullFaceNone, CullFaceBack, CullFaceFront, CullFaceFrontBack, FrontFaceDirectionCW, FrontFaceDirectionCCW, BasicShadowMap, PCFShadowMap, PCFSoftShadowMap, FrontSide, BackSide, DoubleSide, FlatShading, SmoothShading, NoColors, FaceColors, VertexColors, NoBlending, NormalBlending, AdditiveBlending, SubtractiveBlending, MultiplyBlending, CustomBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, OneMinusSrcColorFactor, SrcAlphaFactor, OneMinusSrcAlphaFactor, DstAlphaFactor, OneMinusDstAlphaFactor, DstColorFactor, OneMinusDstColorFactor, SrcAlphaSaturateFactor, NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth, MultiplyOperation, MixOperation, AddOperation, NoToneMapping, LinearToneMapping, ReinhardToneMapping, Uncharted2ToneMapping, CineonToneMapping, UVMapping, CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping, SphericalReflectionMapping, CubeUVReflectionMapping, CubeUVRefractionMapping, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter, NearestMipMapNearestFilter, NearestMipMapLinearFilter, LinearFilter, LinearMipMapNearestFilter, LinearMipMapLinearFilter, UnsignedByteType, ByteType, ShortType, UnsignedShortType, IntType, UnsignedIntType, FloatType, HalfFloatType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShort565Type, UnsignedInt248Type, AlphaFormat, RGBFormat, RGBAFormat, LuminanceFormat, LuminanceAlphaFormat, RGBEFormat, DepthFormat, DepthStencilFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, LoopOnce, LoopRepeat, LoopPingPong, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, ZeroCurvatureEnding, ZeroSlopeEnding, WrapAroundEnding, TrianglesDrawMode, TriangleStripDrawMode, TriangleFanDrawMode, LinearEncoding, sRGBEncoding, GammaEncoding, RGBEEncoding, LogLuvEncoding, RGBM7Encoding, RGBM16Encoding, RGBDEncoding, BasicDepthPacking, RGBADepthPacking, BoxGeometry as CubeGeometry, Face4, LineStrip, LinePieces, MeshFaceMaterial, MultiMaterial, PointCloud, Particle, ParticleSystem, PointCloudMaterial, ParticleBasicMaterial, ParticleSystemMaterial, Vertex, DynamicBufferAttribute, Int8Attribute, Uint8Attribute, Uint8ClampedAttribute, Int16Attribute, Uint16Attribute, Int32Attribute, Uint32Attribute, Float32Attribute, Float64Attribute, ClosedSplineCurve3, SplineCurve3, Spline, BoundingBoxHelper, EdgesHelper, WireframeHelper, XHRLoader, BinaryTextureLoader, GeometryUtils, ImageUtils, Projector, CanvasRenderer };
export { WebGLRenderTargetCube, WebGLRenderTarget, WebGLRenderer, ShaderLib, UniformsLib, UniformsUtils, ShaderChunk, FogExp2, Fog, Scene, LensFlare, Sprite, LOD, SkinnedMesh, Skeleton, Bone, Mesh, LineSegments, LineLoop, Line, Points, Group, VideoTexture, DataTexture, CompressedTexture, CubeTexture, CanvasTexture, DepthTexture, Texture, CompressedTextureLoader, DataTextureLoader, CubeTextureLoader, TextureLoader, ObjectLoader, MaterialLoader, BufferGeometryLoader, DefaultLoadingManager, LoadingManager, JSONLoader, ImageLoader, FontLoader, FileLoader, Loader, Cache, AudioLoader, SpotLightShadow, SpotLight, PointLight, RectAreaLight, HemisphereLight, DirectionalLightShadow, DirectionalLight, AmbientLight, LightShadow, Light, StereoCamera, PerspectiveCamera, OrthographicCamera, CubeCamera, ArrayCamera, Camera, AudioListener, PositionalAudio, AudioContext, AudioAnalyser, Audio, VectorKeyframeTrack, StringKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, ColorKeyframeTrack, BooleanKeyframeTrack, PropertyMixer, PropertyBinding, KeyframeTrack, AnimationUtils, AnimationObjectGroup, AnimationMixer, AnimationClip, Uniform, InstancedBufferGeometry, BufferGeometry, GeometryIdCount, Geometry, InterleavedBufferAttribute, InstancedInterleavedBuffer, InterleavedBuffer, InstancedBufferAttribute, Face3, Object3D, Raycaster, Layers, EventDispatcher, Clock, QuaternionLinearInterpolant, LinearInterpolant, DiscreteInterpolant, CubicInterpolant, Interpolant, Triangle, _Math as Math, Spherical, Cylindrical, Plane, Frustum, Sphere, Ray, Matrix4, Matrix3, Box3, Box2, Line3, Euler, Vector4, Vector3, Vector2, Quaternion, Color, MorphBlendMesh, ImmediateRenderObject, VertexNormalsHelper, SpotLightHelper, SkeletonHelper, PointLightHelper, RectAreaLightHelper, HemisphereLightHelper, GridHelper, PolarGridHelper, FaceNormalsHelper, DirectionalLightHelper, CameraHelper, BoxHelper, ArrowHelper, AxisHelper, CatmullRomCurve3, CubicBezierCurve3, QuadraticBezierCurve3, LineCurve3, ArcCurve, EllipseCurve, SplineCurve, CubicBezierCurve, QuadraticBezierCurve, LineCurve, Shape, Path, ShapePath, Font, CurvePath, Curve, ShapeUtils, SceneUtils, WireframeGeometry, ParametricGeometry, ParametricBufferGeometry, TetrahedronGeometry, TetrahedronBufferGeometry, OctahedronGeometry, OctahedronBufferGeometry, IcosahedronGeometry, IcosahedronBufferGeometry, DodecahedronGeometry, DodecahedronBufferGeometry, PolyhedronGeometry, PolyhedronBufferGeometry, TubeGeometry, TubeBufferGeometry, TorusKnotGeometry, TorusKnotBufferGeometry, TorusGeometry, TorusBufferGeometry, TextGeometry, TextBufferGeometry, SphereGeometry, SphereBufferGeometry, RingGeometry, RingBufferGeometry, PlaneGeometry, PlaneBufferGeometry, LatheGeometry, LatheBufferGeometry, ShapeGeometry, ShapeBufferGeometry, ExtrudeGeometry, ExtrudeBufferGeometry, EdgesGeometry, ConeGeometry, ConeBufferGeometry, CylinderGeometry, CylinderBufferGeometry, CircleGeometry, CircleBufferGeometry, BoxGeometry, BoxBufferGeometry, ShadowMaterial, SpriteMaterial, RawShaderMaterial, ShaderMaterial, PointsMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshPhongMaterial, MeshToonMaterial, MeshNormalMaterial, MeshLambertMaterial, MeshDepthMaterial, MeshBasicMaterial, LineDashedMaterial, LineBasicMaterial, Material, Float64BufferAttribute, Float32BufferAttribute, Uint32BufferAttribute, Int32BufferAttribute, Uint16BufferAttribute, Int16BufferAttribute, Uint8ClampedBufferAttribute, Uint8BufferAttribute, Int8BufferAttribute, BufferAttribute, REVISION, MOUSE, CullFaceNone, CullFaceBack, CullFaceFront, CullFaceFrontBack, FrontFaceDirectionCW, FrontFaceDirectionCCW, BasicShadowMap, PCFShadowMap, PCFSoftShadowMap, FrontSide, BackSide, DoubleSide, FlatShading, SmoothShading, NoColors, FaceColors, VertexColors, NoBlending, NormalBlending, AdditiveBlending, SubtractiveBlending, MultiplyBlending, CustomBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, OneMinusSrcColorFactor, SrcAlphaFactor, OneMinusSrcAlphaFactor, DstAlphaFactor, OneMinusDstAlphaFactor, DstColorFactor, OneMinusDstColorFactor, SrcAlphaSaturateFactor, NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth, MultiplyOperation, MixOperation, AddOperation, NoToneMapping, LinearToneMapping, ReinhardToneMapping, Uncharted2ToneMapping, CineonToneMapping, UVMapping, CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping, SphericalReflectionMapping, CubeUVReflectionMapping, CubeUVRefractionMapping, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter, NearestMipMapNearestFilter, NearestMipMapLinearFilter, LinearFilter, LinearMipMapNearestFilter, LinearMipMapLinearFilter, UnsignedByteType, ByteType, ShortType, UnsignedShortType, IntType, UnsignedIntType, FloatType, HalfFloatType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShort565Type, UnsignedInt248Type, AlphaFormat, RGBFormat, RGBAFormat, LuminanceFormat, LuminanceAlphaFormat, RGBEFormat, DepthFormat, DepthStencilFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, LoopOnce, LoopRepeat, LoopPingPong, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, ZeroCurvatureEnding, ZeroSlopeEnding, WrapAroundEnding, TrianglesDrawMode, TriangleStripDrawMode, TriangleFanDrawMode, LinearEncoding, sRGBEncoding, GammaEncoding, RGBEEncoding, LogLuvEncoding, RGBM7Encoding, RGBM16Encoding, RGBDEncoding, BasicDepthPacking, RGBADepthPacking, BoxGeometry as CubeGeometry, Face4, LineStrip, LinePieces, MeshFaceMaterial, MultiMaterial, PointCloud, Particle, ParticleSystem, PointCloudMaterial, ParticleBasicMaterial, ParticleSystemMaterial, Vertex, DynamicBufferAttribute, Int8Attribute, Uint8Attribute, Uint8ClampedAttribute, Int16Attribute, Uint16Attribute, Int32Attribute, Uint32Attribute, Float32Attribute, Float64Attribute, ClosedSplineCurve3, SplineCurve3, Spline, BoundingBoxHelper, EdgesHelper, WireframeHelper, XHRLoader, BinaryTextureLoader, GeometryUtils, ImageUtils, Projector, CanvasRenderer };
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:BufferGeometry] &rarr;
<h1>[name]</h1>
<div class="desc">Creates extruded BufferGeometry from a path shape.</div>
<iframe id="scene" src="scenes/geometry-browser.html#ExtrudeBufferGeometry"></iframe>
<script>
// iOS iframe auto-resize workaround
if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
var scene = document.getElementById( 'scene' );
scene.style.width = getComputedStyle( scene ).width;
scene.style.height = getComputedStyle( scene ).height;
scene.setAttribute( 'scrolling', 'no' );
}
</script>
<h2>Example</h2>
<code>
var length = 12, width = 8;
var shape = new THREE.Shape();
shape.moveTo( 0,0 );
shape.lineTo( 0, width );
shape.lineTo( length, width );
shape.lineTo( length, 0 );
shape.lineTo( 0, 0 );
var extrudeSettings = {
steps: 2,
amount: 16,
bevelEnabled: true,
bevelThickness: 1,
bevelSize: 1,
bevelSegments: 1
};
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
var mesh = new THREE.Mesh( geometry, material ) ;
scene.add( mesh );
</code>
<h2>Constructor</h2>
<h3>[name]([page:Array shapes], [page:Object options])</h3>
<div>
shapes — Shape or an array of shapes. <br />
options — Object that can contain the following parameters.
<ul>
<li>curveSegments — int. Number of points on the curves. Default is 12.</li>
<li>steps — int. Number of points used for subdividing segments along the depth of the extruded spline. Default is 1.</li>
<li>amount — int. 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>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 (creates Frames if frames aren't defined).</li>
<li>frames — An instance of THREE.TubeGeometry.FrenetFrames containing arrays of tangents, normals, binormals for each step along the extrudePath. </li>
<li>UVGenerator — Object. object that provides UV generator functions</li>
</ul>
</div>
<div>
This object extrudes a 2D shape to a 3D geometry.
</div>
<div>
When creating a Mesh with this geometry, if you'd like to have a separate material used for its face
and its extruded sides, you can use an instance of THREE.MultiMaterial. The first material will be
applied to the face; the second material will be applied to the sides.
</div>
<h2>Properties</h2>
<h2>Methods</h2>
<h3>[method:null addShapeList]([page:Array shapes], [page:Object options])</h3>
<div>
shapes — An Array of shapes to add. <br />
options — Object that can contain the following parameters.
<ul>
<li>curveSegments — int. Number of points on the curves. Default is 12.</li>
<li>steps — int. Number of points used for subdividing segments along the depth of the extruded spline. Default is 1.</li>
<li>amount — int. 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>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 (creates Frames if frames aren't defined).</li>
<li>frames — An instance of THREE.TubeGeometry.FrenetFrames containing arrays of tangents, normals, binormals for each step along the extrudePath. </li>
<li>UVGenerator — Object. object that provides UV generator functions</li>
</ul>
</div>
<div>Adds the shapes to the list to extrude.</div>
<h3>[method:null addShape]([page:Shape shape], [page:Object options])</h3>
<div>
shape — A shape to add. <br />
options — Object that can contain the following parameters.
<ul>
<li>curveSegments — int. Number of points on the curves. Default is 12.</li>
<li>steps — int. Number of points used for subdividing segments along the depth of the extruded spline. Default is 1.</li>
<li>amount — int. 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>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 (creates Frames if frames aren't defined).</li>
<li>frames — An instance of THREE.TubeGeometry.FrenetFrames containing arrays of tangents, normals, binormals for each step along the extrudePath. </li>
<li>UVGenerator — Object. object that provides UV generator functions</li>
</ul>
</div>
<div>Add the shape to the list to extrude.</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
......@@ -15,7 +15,7 @@
<div class="desc">
A material for shiny surfaces with specular highlights.<br /><br />
The uses a non-physically based [link:https://en.wikipedia.org/wiki/LBlinn-Phong_shading_model Blinn-Phong]
The uses a non-physically based [link:https://en.wikipedia.org/wiki/Blinn-Phong_shading_model Blinn-Phong]
model for calculating reflectance. Unlike the Lambertian model used in the [page:MeshLambertMaterial]
this can simulate shiny surfaces with specular highlights (such as varnished wood).<br /><br />
......
......@@ -12,22 +12,41 @@
<h1>[name]</h1>
<div class="desc">
A loader for loading a *gltf* resource in JSON format.
A loader for *glTF* 2.0 resources.
<br /><br />
The <a href="https://www.khronos.org/gltf">glTF file format</a> is a JSON file format to enable rapid delivery and loading of 3D content.
<a href="https://www.khronos.org/gltf">glTF</a> (GL Transmission Format) is an open format
specification for efficient delivery and loading of 3D content. Assets may be provided either
in JSON (.gltf) or binary (.glb) format. External files store textures (.jpg, .png, ...) and
additional binary data (.bin). A glTF asset may deliver one or more scenes, including meshes,
materials, textures, shaders, skins, skeletons, animations, lights, and/or cameras. Morph target
animations are not yet finalized in the
<a href="https://github.com/KhronosGroup/glTF/tree/master/specification">glTF specification</a>.
</div>
<h2>Notes</h2>
<h2>Extensions</h2>
<div>
When using custom shaders provided within a glTF file [page:THREE.GLTFLoader.Shaders] should be updated on each render loop. See [example:webgl_loader_gltf] demo source code for example usage.
GLTF2Loader supports the following glTF extensions:
</div>
<ul>
<li>
<a target="_blank" href="https://github.com/KhronosGroup/glTF/blob/master/extensions/Khronos/KHR_binary_glTF">
KHR_binary_glTF
</a>
</li>
<li>
<a target="_blank" href="https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_materials_common">
KHR_materials_common
</a>
</li>
</ul>
<h2>Example</h2>
<code>
// Instantiate a loader
var loader = new THREE.GLTFLoader();
var loader = new THREE.GLTF2Loader();
// Load a glTF resource
loader.load( 'models/gltf/duck/duck.gltf', function ( gltf ) {
......@@ -40,7 +59,7 @@
} );
</code>
[example:webgl_loader_gltf]
[example:webgl_loader_gltf2]
<h2>Constructor</h2>
......@@ -88,11 +107,11 @@
[page:String path] — The base path from which to find subsequent glTF resources such as textures, GLSL shaders and .bin data files.<br />
</div>
<div>
Parse a glTF-based <em>JSON</em> structure and fire [page:Function callback] when complete. The argument to [page:Function callback] will be an [page:object] that contains loaded parts: .[page:Scene scene], .[page:Array cameras], .[page:Array animations] and .[page:Array shaders]
Parse a glTF-based <em>JSON</em> structure and fire [page:Function callback] when complete. The argument to [page:Function callback] will be an [page:object] that contains loaded parts: .[page:Scene scene], .[page:Array scenes], .[page:Array cameras], and .[page:Array animations].
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js examples/js/loaders/GLTFLoader.js]
[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTF2Loader.js examples/js/loaders/GLTF2Loader.js]
</body>
</html>
......@@ -145,6 +145,7 @@ var list = {
[ "DodecahedronGeometry", "api/geometries/DodecahedronGeometry" ],
[ "EdgesGeometry", "api/geometries/EdgesGeometry" ],
[ "ExtrudeGeometry", "api/geometries/ExtrudeGeometry" ],
[ "ExtrudeBufferGeometry", "api/geometries/ExtrudeBufferGeometry" ],
[ "IcosahedronBufferGeometry", "api/geometries/IcosahedronBufferGeometry" ],
[ "IcosahedronGeometry", "api/geometries/IcosahedronGeometry" ],
[ "LatheBufferGeometry", "api/geometries/LatheBufferGeometry" ],
......@@ -339,7 +340,7 @@ var list = {
"Loaders": [
[ "BabylonLoader", "examples/loaders/BabylonLoader" ],
[ "ColladaLoader", "examples/loaders/ColladaLoader" ],
[ "GLTFLoader", "examples/loaders/GLTFLoader" ],
[ "GLTF2Loader", "examples/loaders/GLTF2Loader" ],
[ "MTLLoader", "examples/loaders/MTLLoader" ],
[ "OBJLoader", "examples/loaders/OBJLoader" ],
[ "PCDLoader", "examples/loaders/PCDLoader" ],
......
......@@ -32,7 +32,7 @@ TODO
The key equation to solving this is this formula for the visible height at a given distance:
<code>s
<code>
visible_height = 2 * Math.tan( ( Math.PI / 180 ) * camera.fov / 2 ) * distance_from_camera;
</code>
If we increase the window height by a certain percentage, then what we want is the visible height at all distances
......
......@@ -49,7 +49,7 @@ object.updateMatrix();
You can however update the content of buffers.
</p>
<p>
This means that if you know an attribute of you BufferGeometry will grow, say the number of vertices,
This means that if you know an attribute of your BufferGeometry will grow, say the number of vertices,
you must pre-allocate a buffer large enough to hold any new vertices that may be created. Of
course, this also means that there will be a maximum size for your BufferGeometry - there is
no way to create a BufferGeometry that can efficiently be extended indefinitely.
......@@ -127,10 +127,10 @@ line.geometry.attributes.position.needsUpdate = true; // required after the firs
<h3>[page:Geometry]</h3>
<div>
<p>
The following flag control updating of various geometry attributes. Set flags only
The following flags control updating of various geometry attributes. Set flags only
for attributes that you need to update, updates are costly. Once buffers
change, these flags reset automatically back to false. You need to keep setting them to
true if you wanna keep updating buffers. Note that this applies only to [page:Geometry]
true if you want to keep updating buffers. Note that this applies only to [page:Geometry]
and not to [page:BufferGeometry].
</p>
<code>
......
......@@ -1300,6 +1300,46 @@ var guis = {
generateGeometry();
},
ExtrudeBufferGeometry: function( mesh ) {
var data = {
steps: 2,
amount: 16,
bevelEnabled: true,
bevelThickness: 1,
bevelSize: 1,
bevelSegments: 1
};
var length = 12, width = 8;
var shape = new THREE.Shape();
shape.moveTo( 0,0 );
shape.lineTo( 0, width );
shape.lineTo( length, width );
shape.lineTo( length, 0 );
shape.lineTo( 0, 0 );
function generateGeometry() {
updateGroupGeometry( mesh,
new THREE.ExtrudeBufferGeometry( shape, data )
);
}
var folder = gui.addFolder( 'THREE.ExtrudeGeometry' );
folder.add( data, 'steps', 1, 10 ).step( 1 ).onChange( generateGeometry );
folder.add( data, 'amount', 1, 20 ).step( 1 ).onChange( generateGeometry );
folder.add( data, 'bevelThickness', 1, 5 ).step( 1 ).onChange( generateGeometry );
folder.add( data, 'bevelSize', 1, 5 ).step( 1 ).onChange( generateGeometry );
folder.add( data, 'bevelSegments', 1, 5 ).step( 1 ).onChange( generateGeometry );
generateGeometry();
}
};
......
......@@ -102,7 +102,7 @@ Sidebar.Script = function ( editor ) {
signals.objectSelected.add( function ( object ) {
if ( object !== null ) {
if ( object !== null && editor.camera !== object ) {
container.setDisplay( 'block' );
......
......@@ -89,6 +89,7 @@ var files = {
"webgl_loader_ctm_materials",
"webgl_loader_fbx",
"webgl_loader_gltf",
"webgl_loader_gltf2",
"webgl_loader_json_blender",
"webgl_loader_json_claraio",
"webgl_loader_json_objconverter",
......@@ -117,6 +118,7 @@ var files = {
"webgl_loader_utf8",
"webgl_loader_vrml",
"webgl_loader_vtk",
"webgl_loader_x",
"webgl_lod",
"webgl_marchingcubes",
"webgl_materials",
......
......@@ -37,7 +37,7 @@ THREE.VRControls = function ( object, onError ) {
if ( navigator.getVRDisplays ) {
navigator.getVRDisplays().then( gotVRDisplays ).catch ( function () {
navigator.getVRDisplays().then( gotVRDisplays ).catch( function () {
console.warn( 'THREE.VRControls: Unable to get VR Displays' );
......
/**
* @author Jey-en https://github.com/adrs2002
*
* this loader repo -> https://github.com/adrs2002/threeXLoader
*
* This loader is load model (and animation) from .X file format. (for old DirectX).
* ! this version are load from TEXT format .X only ! not a Binary.
*
* Support
* - mesh
* - texture
* - normal / uv
* - material
* - skinning
*
* Not Support
* - template
* - material(ditail)
* - morph
* - scene
*/
var XfileLoadMode$1 = XfileLoadMode = {
none: -1,
Element: 1,
FrameTransformMatrix_Read: 3,
Mesh: 5,
Vartex_init: 10,
Vartex_Read: 11,
Index_init: 20,
index_Read: 21,
Uv_init: 30,
Uv_Read: 31,
Normal_V_init: 40,
Normal_V_Read: 41,
Normal_I_init: 42,
Normal_I_Read: 43,
Mat_Face_init: 101,
Mat_Face_len_Read: 102,
Mat_Face_Set: 103,
Mat_Set: 111,
Mat_Set_Texture: 121,
Mat_Set_LightTex: 122,
Mat_Set_EmissiveTex: 123,
Mat_Set_BumpTex: 124,
Mat_Set_NormalTex: 125,
Mat_Set_EnvTex: 126,
Weit_init: 201,
Weit_IndexLength: 202,
Weit_Read_Index: 203,
Weit_Read_Value: 204,
Weit_Read_Matrx: 205,
Anim_init: 1001,
Anim_Reading: 1002,
Anim_KeyValueTypeRead: 1003,
Anim_KeyValueLength: 1004,
Anime_ReadKeyFrame: 1005
};
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var XAnimationObj = function () {
function XAnimationObj() {
classCallCheck(this, XAnimationObj);
this.fps = 30;
this.name = 'xanimation';
this.length = 0;
this.hierarchy = [];
}
createClass(XAnimationObj, [{
key: 'make',
value: function make(XAnimationInfoArray, mesh) {
var keys = Object.keys(XAnimationInfoArray);
var hierarchy_tmp = [];
for (var i = 0; i < keys.length; i++) {
var bone = null;
var parent = -1;
var baseIndex = -1;
for (var m = 0; m < mesh.skeleton.bones.length; m++) {
if (mesh.skeleton.bones[m].name == XAnimationInfoArray[keys[i]].boneName) {
bone = XAnimationInfoArray[keys[i]].boneName;
parent = mesh.skeleton.bones[m].parent.name;
baseIndex = m;
break;
}
}
hierarchy_tmp[baseIndex] = this.makeBonekeys(XAnimationInfoArray[keys[i]], bone, parent);
}
var keys2 = Object.keys(hierarchy_tmp);
for (var _i = 0; _i < keys2.length; _i++) {
this.hierarchy.push(hierarchy_tmp[_i]);
var parentId = -1;
for (var _m = 0; _m < this.hierarchy.length; _m++) {
if (_i != _m && this.hierarchy[_i].parent === this.hierarchy[_m].name) {
parentId = _m;
break;
}
}
this.hierarchy[_i].parent = parentId;
}
}
}, {
key: 'makeBonekeys',
value: function makeBonekeys(XAnimationInfo, bone, parent) {
var refObj = {};
refObj.name = bone;
refObj.parent = parent;
refObj.keys = [];
for (var i = 0; i < XAnimationInfo.keyFrames.length; i++) {
var keyframe = {};
keyframe.time = XAnimationInfo.keyFrames[i].time * this.fps;
keyframe.matrix = XAnimationInfo.keyFrames[i].matrix;
keyframe.pos = new THREE.Vector3().setFromMatrixPosition(keyframe.matrix);
keyframe.rot = new THREE.Quaternion().setFromRotationMatrix(keyframe.matrix);
keyframe.scl = new THREE.Vector3().setFromMatrixScale(keyframe.matrix);
refObj.keys.push(keyframe);
}
return refObj;
}
}]);
return XAnimationObj;
}();
var Xdata = function Xdata() {
classCallCheck(this, Xdata);
this.FrameInfo = [];
this.FrameInfo_Raw = [];
this.AnimationSetInfo = [];
this.AnimTicksPerSecond = 60;
this.XAnimationObj = null;
};
var XboneInf = function XboneInf() {
classCallCheck(this, XboneInf);
this.boneName = "";
this.BoneIndex = 0;
this.Indeces = [];
this.Weights = [];
this.initMatrix = null;
this.OffsetMatrix = null;
};
var XAnimationInfo$1 = XAnimationInfo = function XAnimationInfo() {
this.animeName = "";
this.boneName = "";
this.targetBone = null;
this.frameStartLv = 0;
this.keyFrames = [];
this.InverseMx = null;
};
var XFrameInfo$1 = XFrameInfo = function XFrameInfo() {
this.Mesh = null;
this.Geometry = null;
this.FrameName = "";
this.ParentName = "";
this.frameStartLv = 0;
this.FrameTransformMatrix = null;
this.children = [];
this.BoneInfs = [];
this.VertexSetedBoneCount = [];
this.Materials = [];
};
var XKeyFrameInfo = function XKeyFrameInfo() {
classCallCheck(this, XKeyFrameInfo);
this.index = 0;
this.Frame = 0;
this.time = 0.0;
this.matrix = null;
};
THREE.XLoader = function () {
function XLoader(manager, Texloader, _zflg) {
classCallCheck(this, XLoader);
this.manager = manager !== undefined ? manager : new THREE.LoadingManager();
this.Texloader = Texloader !== undefined ? Texloader : new THREE.TextureLoader();
this.zflg = _zflg === undefined ? false : _zflg;
this.url = "";
this.baseDir = "";
this.nowReadMode = XfileLoadMode$1.none;
this.nowAnimationKeyType = 4;
this.tgtLength = 0;
this.nowReaded = 0;
this.elementLv = 0;
this.geoStartLv = Number.MAX_VALUE;
this.frameStartLv = Number.MAX_VALUE;
this.matReadLine = 0;
this.putMatLength = 0;
this.nowMat = null;
this.BoneInf = new XboneInf();
this.tmpUvArray = [];
this.normalVectors = [];
this.facesNormal = [];
this.nowFrameName = "";
this.nowAnimationSetName = "";
this.frameHierarchie = [];
this.endLineCount = 0;
this.geometry = null;
this.loadingXdata = null;
this.lines = null;
this.keyInfo = null;
this.animeKeyNames = null;
this.data = null;
this.onLoad = null;
}
createClass(XLoader, [{
key: 'load',
value: function load(_arg, onLoad, onProgress, onError) {
var _this = this;
var loader = new THREE.FileLoader(this.manager);
loader.setResponseType('arraybuffer');
for (var i = 0; i < _arg.length; i++) {
switch (i) {
case 0:
this.url = _arg[i];break;
case 1:
this.zflg = _arg[i];break;
}
}
loader.load(this.url, function (response) {
_this.parse(response, onLoad);
}, onProgress, onError);
}
}, {
key: 'isBinary',
value: function isBinary(binData) {
var reader = new DataView(binData);
var face_size = 32 / 8 * 3 + 32 / 8 * 3 * 3 + 16 / 8;
var n_faces = reader.getUint32(80, true);
var expect = 80 + 32 / 8 + n_faces * face_size;
if (expect === reader.byteLength) {
return true;
}
var fileLength = reader.byteLength;
for (var index = 0; index < fileLength; index++) {
if (reader.getUint8(index, false) > 127) {
return true;
}
}
return false;
}
}, {
key: 'ensureBinary',
value: function ensureBinary(buf) {
if (typeof buf === "string") {
var array_buffer = new Uint8Array(buf.length);
for (var i = 0; i < buf.length; i++) {
array_buffer[i] = buf.charCodeAt(i) & 0xff;
}
return array_buffer.buffer || array_buffer;
} else {
return buf;
}
}
}, {
key: 'ensureString',
value: function ensureString(buf) {
if (typeof buf !== "string") {
var array_buffer = new Uint8Array(buf);
var str = '';
for (var i = 0; i < buf.byteLength; i++) {
str += String.fromCharCode(array_buffer[i]);
}
return str;
} else {
return buf;
}
}
}, {
key: 'parse',
value: function parse(data, onLoad) {
var binData = this.ensureBinary(data);
this.data = this.ensureString(data);
this.onLoad = onLoad;
return this.isBinary(binData) ? this.parseBinary(binData) : this.parseASCII();
}
}, {
key: 'parseBinary',
value: function parseBinary(data) {
return parseASCII(String.fromCharCode.apply(null, data));
}
}, {
key: 'parseASCII',
value: function parseASCII() {
var baseDir = "";
if (this.url.lastIndexOf("/") > 0) {
this.baseDir = this.url.substr(0, this.url.lastIndexOf("/") + 1);
}
this.loadingXdata = new Xdata();
this.lines = this.data.split("\n");
this.mainloop();
}
}, {
key: 'mainloop',
value: function mainloop() {
var _this2 = this;
var EndFlg = false;
for (var i = 0; i < 100; i++) {
this.lineRead(this.lines[this.endLineCount].trim());
this.endLineCount++;
if (this.endLineCount >= this.lines.length - 1) {
EndFlg = true;
this.readFinalize();
setTimeout(function () {
_this2.animationFinalize();
}, 1);
break;
}
}
if (!EndFlg) {
setTimeout(function () {
_this2.mainloop();
}, 1);
}
}
}, {
key: 'lineRead',
value: function lineRead(line) {
if (line.indexOf("template ") > -1) {
return;
}
if (line.length === 0) {
return;
}
if (line.indexOf("{") > -1) {
this.elementLv++;
}
if (line.indexOf("AnimTicksPerSecond") > -1) {
var findA = line.indexOf("{");
this.loadingXdata.AnimTicksPerSecond = parseInt(line.substr(findA + 1, line.indexOf(";") - findA + 1), 10);
}
if (line.indexOf("}") > -1) {
if (this.elementLv < 1 || this.nowFrameName === "") {
this.elementLv = 0;return;
}
this.endElement();
return;
}
if (line.indexOf("Frame ") > -1) {
this.beginFrame(line);
return;
}
if (line.indexOf("FrameTransformMatrix") > -1) {
this.nowReadMode = XfileLoadMode$1.FrameTransformMatrix_Read;
return;
}
if (this.nowReadMode === XfileLoadMode$1.FrameTransformMatrix_Read) {
var data = line.split(",");
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].FrameTransformMatrix = new THREE.Matrix4();
this.ParseMatrixData(this.loadingXdata.FrameInfo_Raw[this.nowFrameName].FrameTransformMatrix, data);
this.nowReadMode = XfileLoadMode$1.Element;
return;
}
if (line.indexOf("Mesh ") > -1) {
this.beginReadMesh(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Vartex_init) {
this.readVertexCount(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Vartex_Read) {
if (this.readVertex(line)) {
return;
}
}
if (this.nowReadMode === XfileLoadMode$1.Index_init) {
this.readIndexLength(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.index_Read) {
if (this.readVertexIndex(line)) {
return;
}
}
if (line.indexOf("MeshNormals ") > -1) {
this.beginMeshNormal(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Normal_V_init) {
this.readMeshNormalCount(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Normal_V_Read) {
if (this.readMeshNormalVertex(line)) {
return;
}
}
if (this.nowReadMode === XfileLoadMode$1.Normal_I_init) {
this.readMeshNormalIndexCount(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Normal_I_Read) {
if (this.readMeshNormalIndex(line)) {
return;
}
}
if (line.indexOf("MeshTextureCoords ") > -1) {
this.nowReadMode = XfileLoadMode$1.Uv_init;return;
}
if (this.nowReadMode === XfileLoadMode$1.Uv_init) {
this.readUvInit(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Uv_Read) {
if (this.readUv(line)) {
return;
}
}
if (line.indexOf("MeshMaterialList ") > -1) {
this.nowReadMode = XfileLoadMode$1.Mat_Face_init;
return;
}
if (this.nowReadMode === XfileLoadMode$1.Mat_Face_init) {
this.nowReadMode = XfileLoadMode$1.Mat_Face_len_Read;
return;
}
if (this.nowReadMode === XfileLoadMode$1.Mat_Face_len_Read) {
this.readMatrixSetLength(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Mat_Face_Set) {
if (this.readMaterialBind(line)) {
return;
}
}
if (line.indexOf("Material ") > -1) {
this.readMaterialInit(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Mat_Set) {
this.readandSetMaterial(line);return;
}
if (this.nowReadMode >= XfileLoadMode$1.Mat_Set_Texture && this.nowReadMode < XfileLoadMode$1.Weit_init) {
this.readandSetMaterialTexture(line);return;
}
if (line.indexOf("SkinWeights ") > -1 && this.nowReadMode >= XfileLoadMode$1.Element) {
this.readBoneInit(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Weit_init) {
this.readBoneName(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Weit_IndexLength) {
this.readBoneVertexLength(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Weit_Read_Index) {
this.readandSetBoneVertex(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Weit_Read_Value) {
this.readandSetBoneWeightValue(line);return;
}
if (this.nowReadMode === XfileLoadMode$1.Weit_Read_Matrx) {
this.readandSetBoneOffsetMatrixValue(line);return;
}
if (line.indexOf("AnimationSet ") > -1) {
this.readandCreateAnimationSet(line);return;
}
if (line.indexOf("Animation ") > -1 && this.nowReadMode === XfileLoadMode$1.Anim_init) {
this.readAndCreateAnimation(line);return;
}
if (line.indexOf("AnimationKey ") > -1) {
this.nowReadMode = XfileLoadMode$1.Anim_KeyValueTypeRead;return;
}
if (this.nowReadMode === XfileLoadMode$1.Anim_KeyValueTypeRead) {
this.nowAnimationKeyType = parseInt(line.substr(0, line.length - 1), 10);
this.nowReadMode = XfileLoadMode$1.Anim_KeyValueLength;
return;
}
if (this.nowReadMode === XfileLoadMode$1.Anim_KeyValueLength) {
this.tgtLength = parseInt(line.substr(0, line.length - 1), 10);
this.nowReaded = 0;
this.nowReadMode = XfileLoadMode$1.Anime_ReadKeyFrame;
return;
}
if (this.nowReadMode === XfileLoadMode$1.Anime_ReadKeyFrame) {
this.readAnimationKeyFrame(line);return;
}
}
}, {
key: 'endElement',
value: function endElement(line) {
if (this.nowReadMode < XfileLoadMode$1.Anim_init && this.loadingXdata.FrameInfo_Raw[this.nowFrameName].FrameStartLv === this.elementLv && this.nowReadMode > XfileLoadMode$1.none) {
if (this.frameHierarchie.length > 0) {
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].children = [];
var keys = Object.keys(this.loadingXdata.FrameInfo_Raw);
for (var m = 0; m < keys.length; m++) {
if (this.loadingXdata.FrameInfo_Raw[keys[m]].ParentName === this.nowFrameName) {
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].children.push(keys[m]);
}
}
this.frameHierarchie.pop();
}
this.MakeOutputGeometry(this.nowFrameName, this.zflg);
this.frameStartLv = this.loadingXdata.FrameInfo_Raw[this.nowFrameName].FrameStartLv;
if (this.frameHierarchie.length > 0) {
this.nowFrameName = this.frameHierarchie[this.frameHierarchie.length - 1];
this.frameStartLv = this.loadingXdata.FrameInfo_Raw[this.nowFrameName].FrameStartLv;
} else {
this.nowFrameName = "";
}
}
if (this.nowReadMode === XfileLoadMode$1.Mat_Set) {
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Materials.push(this.nowMat);
this.nowReadMode = XfileLoadMode$1.Element;
}
this.elementLv--;
}
}, {
key: 'beginFrame',
value: function beginFrame(line) {
this.frameStartLv = this.elementLv;
this.nowReadMode = XfileLoadMode$1.Element;
this.nowFrameName = line.substr(6, line.length - 8);
this.loadingXdata.FrameInfo_Raw[this.nowFrameName] = new XFrameInfo$1();
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].FrameName = this.nowFrameName;
if (this.frameHierarchie.length > 0) {
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].ParentName = this.frameHierarchie[this.frameHierarchie.length - 1];
}
this.frameHierarchie.push(this.nowFrameName);
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].FrameStartLv = this.frameStartLv;
}
}, {
key: 'beginReadMesh',
value: function beginReadMesh(line) {
if (this.nowFrameName === "") {
this.frameStartLv = this.elementLv;
this.nowFrameName = line.substr(5, line.length - 6);
if (this.nowFrameName === "") {
this.nowFrameName = "mesh_" + this.loadingXdata.FrameInfo_Raw.length;
}
this.loadingXdata.FrameInfo_Raw[this.nowFrameName] = new XFrameInfo$1();
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].FrameName = this.nowFrameName;
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].FrameStartLv = this.frameStartLv;
}
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry = new THREE.Geometry();
this.geoStartLv = this.elementLv;
this.nowReadMode = XfileLoadMode$1.Vartex_init;
Bones = [];
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Materials = [];
}
}, {
key: 'readVertexCount',
value: function readVertexCount(line) {
this.nowReadMode = XfileLoadMode$1.Vartex_Read;
this.tgtLength = parseInt(line.substr(0, line.length - 1), 10);
this.nowReaded = 0;
}
}, {
key: 'readVertex',
value: function readVertex(line) {
var data = line.substr(0, line.length - 2).split(";");
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.vertices.push(new THREE.Vector3(parseFloat(data[0]), parseFloat(data[1]), parseFloat(data[2])));
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.skinIndices.push(new THREE.Vector4(0, 0, 0, 0));
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.skinWeights.push(new THREE.Vector4(1, 0, 0, 0));
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].VertexSetedBoneCount.push(0);
this.nowReaded++;
if (this.nowReaded >= this.tgtLength) {
this.nowReadMode = XfileLoadMode$1.Index_init;
return true;
}
return false;
}
}, {
key: 'readIndexLength',
value: function readIndexLength(line) {
this.nowReadMode = XfileLoadMode$1.index_Read;
this.tgtLength = parseInt(line.substr(0, line.length - 1), 10);
this.nowReaded = 0;
}
}, {
key: 'readVertexIndex',
value: function readVertexIndex(line) {
var data = line.substr(2, line.length - 4).split(",");
if (this.zflg) {
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faces.push(new THREE.Face3(parseInt(data[2], 10), parseInt(data[1], 10), parseInt(data[0], 10), new THREE.Vector3(1, 1, 1).normalize()));
} else {
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faces.push(new THREE.Face3(parseInt(data[0], 10), parseInt(data[1], 10), parseInt(data[2], 10), new THREE.Vector3(1, 1, 1).normalize()));
}
this.nowReaded++;
if (this.nowReaded >= this.tgtLength) {
this.nowReadMode = XfileLoadMode$1.Element;
return true;
}
return false;
}
}, {
key: 'beginMeshNormal',
value: function beginMeshNormal(line) {
this.nowReadMode = XfileLoadMode$1.Normal_V_init;
this.normalVectors = [];
this.facesNormal = [];
}
}, {
key: 'readMeshNormalCount',
value: function readMeshNormalCount(line) {
this.nowReadMode = XfileLoadMode$1.Normal_V_Read;
this.tgtLength = parseInt(line.substr(0, line.length - 1), 10);
this.nowReaded = 0;
}
}, {
key: 'readMeshNormalVertex',
value: function readMeshNormalVertex(line) {
var data = line.split(";");
this.normalVectors.push([parseFloat(data[0]), parseFloat(data[1]), parseFloat(data[2])]);
this.nowReaded++;
if (this.nowReaded >= this.tgtLength) {
this.nowReadMode = XfileLoadMode$1.Normal_I_init;
return true;
}
return false;
}
}, {
key: 'readMeshNormalIndexCount',
value: function readMeshNormalIndexCount(line) {
this.nowReadMode = XfileLoadMode$1.Normal_I_Read;
this.tgtLength = parseInt(line.substr(0, line.length - 1), 10);
this.nowReaded = 0;
}
}, {
key: 'readMeshNormalIndex',
value: function readMeshNormalIndex(line) {
var data = line.substr(2, line.length - 4).split(",");
var nowID = parseInt(data[0], 10);
var v1 = new THREE.Vector3(this.normalVectors[nowID][0], this.normalVectors[nowID][1], this.normalVectors[nowID][2]);
nowID = parseInt(data[1], 10);
var v2 = new THREE.Vector3(this.normalVectors[nowID][0], this.normalVectors[nowID][1], this.normalVectors[nowID][2]);
nowID = parseInt(data[2], 10);
var v3 = new THREE.Vector3(this.normalVectors[nowID][0], this.normalVectors[nowID][1], this.normalVectors[nowID][2]);
if (this.zflg) {
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faces[this.nowReaded].vertexNormals = [v3, v2, v1];
} else {
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faces[this.nowReaded].vertexNormals = [v1, v2, v3];
}
this.facesNormal.push(v1.normalize());
this.nowReaded++;
if (this.nowReaded >= this.tgtLength) {
this.nowReadMode = XfileLoadMode$1.Element;
return true;
}
return false;
}
}, {
key: 'readUvInit',
value: function readUvInit(line) {
this.nowReadMode = XfileLoadMode$1.Uv_Read;
this.tgtLength = parseInt(line.substr(0, line.length - 1), 10);
this.nowReaded = 0;
this.tmpUvArray = [];
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faceVertexUvs[0] = [];
}
}, {
key: 'readUv',
value: function readUv(line) {
var data = line.split(";");
if (THREE.XLoader.IsUvYReverse) {
this.tmpUvArray.push(new THREE.Vector2(parseFloat(data[0]), 1 - parseFloat(data[1])));
} else {
this.tmpUvArray.push(new THREE.Vector2(parseFloat(data[0]), parseFloat(data[1])));
}
this.nowReaded++;
if (this.nowReaded >= this.tgtLength) {
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faceVertexUvs[0] = [];
for (var m = 0; m < this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faces.length; m++) {
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faceVertexUvs[0][m] = [];
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faceVertexUvs[0][m].push(this.tmpUvArray[this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faces[m].a]);
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faceVertexUvs[0][m].push(this.tmpUvArray[this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faces[m].b]);
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faceVertexUvs[0][m].push(this.tmpUvArray[this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faces[m].c]);
}
this.nowReadMode = XfileLoadMode$1.Element;
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.uvsNeedUpdate = true;
return true;
}
return false;
}
}, {
key: 'readMatrixSetLength',
value: function readMatrixSetLength(line) {
this.nowReadMode = XfileLoadMode$1.Mat_Face_Set;
this.tgtLength = parseInt(line.substr(0, line.length - 1), 10);
this.nowReaded = 0;
}
}, {
key: 'readMaterialBind',
value: function readMaterialBind(line) {
var data = line.split(",");
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].Geometry.faces[this.nowReaded].materialIndex = parseInt(data[0]);
this.nowReaded++;
if (this.nowReaded >= this.tgtLength) {
this.nowReadMode = XfileLoadMode$1.Element;
return true;
}
return false;
}
}, {
key: 'readMaterialInit',
value: function readMaterialInit(line) {
this.nowReadMode = XfileLoadMode$1.Mat_Set;
this.matReadLine = 0;
this.nowMat = new THREE.MeshPhongMaterial({ color: Math.random() * 0xffffff });
var matName = line.substr(9, line.length - 10);
if (matName !== "") {
this.nowMat.name = matName;
}
if (this.zflg) {
this.nowMat.side = THREE.BackSide;
} else {
this.nowMat.side = THREE.FrontSide;
}
this.nowMat.side = THREE.FrontSide;
}
}, {
key: 'readandSetMaterial',
value: function readandSetMaterial(line) {
var data = line.split(";");
this.matReadLine++;
switch (this.matReadLine) {
case 1:
this.nowMat.color.r = data[0];
this.nowMat.color.g = data[1];
this.nowMat.color.b = data[2];
break;
case 2:
this.nowMat.shininess = data[0];
break;
case 3:
this.nowMat.specular.r = data[0];
this.nowMat.specular.g = data[1];
this.nowMat.specular.b = data[2];
break;
case 4:
this.nowMat.emissive.r = data[0];
this.nowMat.emissive.g = data[1];
this.nowMat.emissive.b = data[2];
break;
}
if (line.indexOf("TextureFilename") > -1) {
this.nowReadMode = XfileLoadMode$1.Mat_Set_Texture;
} else if (line.indexOf("BumpMapFilename") > -1) {
this.nowReadMode = XfileLoadMode$1.Mat_Set_BumpTex;
this.nowMat.bumpScale = 0.05;
} else if (line.indexOf("NormalMapFilename") > -1) {
this.nowReadMode = XfileLoadMode$1.Mat_Set_NormalTex;
this.nowMat.normalScale = new THREE.Vector2(2, 2);
} else if (line.indexOf("EmissiveMapFilename") > -1) {
this.nowReadMode = XfileLoadMode$1.Mat_Set_EmissiveTex;
} else if (line.indexOf("LightMapFilename") > -1) {
this.nowReadMode = XfileLoadMode$1.Mat_Set_LightTex;
}
}
}, {
key: 'readandSetMaterialTexture',
value: function readandSetMaterialTexture(line) {
var data = line.substr(1, line.length - 3);
if (data != undefined && data.length > 0) {
switch (this.nowReadMode) {
case XfileLoadMode$1.Mat_Set_Texture:
this.nowMat.map = this.Texloader.load(this.baseDir + data);
break;
case XfileLoadMode$1.Mat_Set_BumpTex:
this.nowMat.bumpMap = this.Texloader.load(this.baseDir + data);
break;
case XfileLoadMode$1.Mat_Set_NormalTex:
this.nowMat.normalMap = this.Texloader.load(this.baseDir + data);
break;
case XfileLoadMode$1.Mat_Set_EmissiveTex:
this.nowMat.emissiveMap = this.Texloader.load(this.baseDir + data);
break;
case XfileLoadMode$1.Mat_Set_LightTex:
this.nowMat.lightMap = this.Texloader.load(this.baseDir + data);
break;
case XfileLoadMode$1.Mat_Set_EnvTex:
this.nowMat.envMap = this.Texloader.load(this.baseDir + data);
break;
}
}
this.nowReadMode = XfileLoadMode$1.Mat_Set;
this.endLineCount++;
this.elementLv--;
}
}, {
key: 'readBoneInit',
value: function readBoneInit(line) {
this.nowReadMode = XfileLoadMode$1.Weit_init;
this.BoneInf = new XboneInf();
}
}, {
key: 'readBoneName',
value: function readBoneName(line) {
this.nowReadMode = XfileLoadMode$1.Weit_IndexLength;
this.BoneInf.boneName = line.substr(1, line.length - 3);
this.BoneInf.BoneIndex = this.loadingXdata.FrameInfo_Raw[this.nowFrameName].BoneInfs.length;
this.nowReaded = 0;
}
}, {
key: 'readBoneVertexLength',
value: function readBoneVertexLength(line) {
this.nowReadMode = XfileLoadMode$1.Weit_Read_Index;
this.tgtLength = parseInt(line.substr(0, line.length - 1), 10);
this.nowReaded = 0;
}
}, {
key: 'readandSetBoneVertex',
value: function readandSetBoneVertex(line) {
this.BoneInf.Indeces.push(parseInt(line.substr(0, line.length - 1), 10));
this.nowReaded++;
if (this.nowReaded >= this.tgtLength || line.indexOf(";") > -1) {
this.nowReadMode = XfileLoadMode$1.Weit_Read_Value;
this.nowReaded = 0;
}
}
}, {
key: 'readandSetBoneWeightValue',
value: function readandSetBoneWeightValue(line) {
var nowVal = parseFloat(line.substr(0, line.length - 1));
this.BoneInf.Weights.push(nowVal);
this.nowReaded++;
if (this.nowReaded >= this.tgtLength || line.indexOf(";") > -1) {
this.nowReadMode = XfileLoadMode$1.Weit_Read_Matrx;
}
}
}, {
key: 'readandSetBoneOffsetMatrixValue',
value: function readandSetBoneOffsetMatrixValue(line) {
var data = line.split(",");
this.BoneInf.initMatrix = new THREE.Matrix4();
this.ParseMatrixData(this.BoneInf.initMatrix, data);
this.BoneInf.OffsetMatrix = new THREE.Matrix4();
this.BoneInf.OffsetMatrix.getInverse(this.BoneInf.initMatrix);
this.loadingXdata.FrameInfo_Raw[this.nowFrameName].BoneInfs.push(this.BoneInf);
this.nowReadMode = XfileLoadMode$1.Element;
}
}, {
key: 'readandCreateAnimationSet',
value: function readandCreateAnimationSet(line) {
this.frameStartLv = this.elementLv;
this.nowReadMode = XfileLoadMode$1.Anim_init;
this.nowAnimationSetName = line.substr(13, line.length - 14).trim();
this.loadingXdata.AnimationSetInfo[this.nowAnimationSetName] = [];
}
}, {
key: 'readAndCreateAnimation',
value: function readAndCreateAnimation(line) {
this.nowFrameName = line.substr(10, line.length - 11).trim();
this.loadingXdata.AnimationSetInfo[this.nowAnimationSetName][this.nowFrameName] = new XAnimationInfo$1();
this.loadingXdata.AnimationSetInfo[this.nowAnimationSetName][this.nowFrameName].animeName = this.nowFrameName;
this.loadingXdata.AnimationSetInfo[this.nowAnimationSetName][this.nowFrameName].FrameStartLv = this.frameStartLv;
while (true) {
this.endLineCount++;
line = this.lines[this.endLineCount].trim();
if (line.indexOf("{") > -1 && line.indexOf("}") > -1) {
this.loadingXdata.AnimationSetInfo[this.nowAnimationSetName][this.nowFrameName].boneName = line.replace(/{/g, "").replace(/}/g, "").trim();
break;
}
}
}
}, {
key: 'readAnimationKeyFrame',
value: function readAnimationKeyFrame(line) {
this.keyInfo = null;
var data = line.split(";");
var nowKeyframe = parseInt(data[0], 10);
var frameFound = false;
var tmpM = new THREE.Matrix4();
if (this.nowAnimationKeyType != 4) {
for (var mm = 0; mm < this.loadingXdata.AnimationSetInfo[this.nowAnimationSetName][this.nowFrameName].keyFrames.length; mm++) {
if (this.loadingXdata.AnimationSetInfo[this.nowAnimationSetName][this.nowFrameName].keyFrames[mm].Frame === nowKeyframe) {
this.keyInfo = this.loadingXdata.AnimationSetInfo[this.nowAnimationSetName][this.nowFrameName].keyFrames[mm];
frameFound = true;
break;
}
}
}
if (!frameFound) {
this.keyInfo = new XKeyFrameInfo();
this.keyInfo.matrix = new THREE.Matrix4();
this.keyInfo.Frame = nowKeyframe;
}
var data2 = data[2].split(",");
switch (this.nowAnimationKeyType) {
case 0:
tmpM.makeRotationFromQuaternion(new THREE.Quaternion(parseFloat(data2[0]), parseFloat(data2[1]), parseFloat(data2[2])));
this.keyInfo.matrix.multiply(tmpM);
break;
case 1:
tmpM.makeScale(parseFloat(data2[0]), parseFloat(data2[1]), parseFloat(data2[2]));
this.keyInfo.matrix.multiply(tmpM);
break;
case 2:
tmpM.makeTranslation(parseFloat(data2[0]), parseFloat(data2[1]), parseFloat(data2[2]));
this.keyInfo.matrix.multiply(tmpM);
break;
case 4:
this.ParseMatrixData(this.keyInfo.matrix, data2);
break;
}
if (!frameFound) {
this.keyInfo.index = this.loadingXdata.AnimationSetInfo[this.nowAnimationSetName][this.nowFrameName].keyFrames.length;
this.keyInfo.time = /*1.0 / this.loadingXdata.AnimTicksPerSecond * */this.keyInfo.Frame;
this.loadingXdata.AnimationSetInfo[this.nowAnimationSetName][this.nowFrameName].keyFrames.push(this.keyInfo);
}
this.nowReaded++;
if (this.nowReaded >= this.tgtLength || line.indexOf(";;;") > -1) {
this.nowReadMode = XfileLoadMode$1.Anim_init;
}
}
}, {
key: 'readFinalize',
value: function readFinalize() {
this.loadingXdata.FrameInfo = [];
var keys = Object.keys(this.loadingXdata.FrameInfo_Raw);
for (var i = 0; i < keys.length; i++) {
if (this.loadingXdata.FrameInfo_Raw[keys[i]].Mesh != null) {
this.loadingXdata.FrameInfo.push(this.loadingXdata.FrameInfo_Raw[keys[i]].Mesh);
}
}
if (this.loadingXdata.FrameInfo != null & this.loadingXdata.FrameInfo.length > 0) {
for (var _i = 0; _i < this.loadingXdata.FrameInfo.length; _i++) {
if (this.loadingXdata.FrameInfo[_i].parent == null) {
this.loadingXdata.FrameInfo[_i].zflag = this.zflg;
if (this.zflg) {
this.loadingXdata.FrameInfo[_i].scale.set(-1, 1, 1);
}
}
}
}
}
}, {
key: 'ParseMatrixData',
value: function ParseMatrixData(targetMatrix, data) {
targetMatrix.set(parseFloat(data[0]), parseFloat(data[4]), parseFloat(data[8]), parseFloat(data[12]), parseFloat(data[1]), parseFloat(data[5]), parseFloat(data[9]), parseFloat(data[13]), parseFloat(data[2]), parseFloat(data[6]), parseFloat(data[10]), parseFloat(data[14]), parseFloat(data[3]), parseFloat(data[7]), parseFloat(data[11]), parseFloat(data[15]));
}
}, {
key: 'MakeOutputGeometry',
value: function MakeOutputGeometry(nowFrameName, _zflg) {
if (this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry != null) {
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.computeBoundingBox();
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.computeBoundingSphere();
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.verticesNeedUpdate = true;
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.normalsNeedUpdate = true;
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.colorsNeedUpdate = true;
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.uvsNeedUpdate = true;
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.groupsNeedUpdate = true;
var putBones = [];
var BoneDics = [];
var rootBone = new THREE.Bone();
if (this.loadingXdata.FrameInfo_Raw[nowFrameName].BoneInfs != null && this.loadingXdata.FrameInfo_Raw[nowFrameName].BoneInfs.length) {
var keys = Object.keys(this.loadingXdata.FrameInfo_Raw);
var BoneDics_Name = [];
for (var m = 0; m < keys.length; m++) {
if (this.loadingXdata.FrameInfo_Raw[keys[m]].FrameStartLv <= this.loadingXdata.FrameInfo_Raw[nowFrameName].FrameStartLv && nowFrameName != keys[m]) {
continue;
}
var b = new THREE.Bone();
b.name = keys[m];
b.applyMatrix(this.loadingXdata.FrameInfo_Raw[keys[m]].FrameTransformMatrix);
b.matrixWorld = b.matrix;
b.FrameTransformMatrix = this.loadingXdata.FrameInfo_Raw[keys[m]].FrameTransformMatrix;
BoneDics_Name[b.name] = putBones.length;
putBones.push(b);
}
for (var _m = 0; _m < putBones.length; _m++) {
for (var dx = 0; dx < this.loadingXdata.FrameInfo_Raw[putBones[_m].name].children.length; dx++) {
var nowBoneIndex = BoneDics_Name[this.loadingXdata.FrameInfo_Raw[putBones[_m].name].children[dx]];
if (putBones[nowBoneIndex] != null) {
putBones[_m].add(putBones[nowBoneIndex]);
}
}
}
}
var mesh = null;
var bufferGeometry = new THREE.BufferGeometry();
if (putBones.length > 0) {
if (this.loadingXdata.FrameInfo_Raw[putBones[0].name].children.length === 0 && nowFrameName != putBones[0].name) {
putBones[0].add(putBones[1]);
putBones[0].zflag = _zflg;
}
for (var _m2 = 0; _m2 < putBones.length; _m2++) {
if (putBones[_m2].parent === null) {
putBones[_m2].zflag = _zflg;
}
for (var bi = 0; bi < this.loadingXdata.FrameInfo_Raw[nowFrameName].BoneInfs.length; bi++) {
if (putBones[_m2].name === this.loadingXdata.FrameInfo_Raw[nowFrameName].BoneInfs[bi].boneName) {
for (var vi = 0; vi < this.loadingXdata.FrameInfo_Raw[nowFrameName].BoneInfs[bi].Indeces.length; vi++) {
var nowVertexID = this.loadingXdata.FrameInfo_Raw[nowFrameName].BoneInfs[bi].Indeces[vi];
var nowVal = this.loadingXdata.FrameInfo_Raw[nowFrameName].BoneInfs[bi].Weights[vi];
switch (this.loadingXdata.FrameInfo_Raw[nowFrameName].VertexSetedBoneCount[nowVertexID]) {
case 0:
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.skinIndices[nowVertexID].x = _m2;
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.skinWeights[nowVertexID].x = nowVal;
break;
case 1:
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.skinIndices[nowVertexID].y = _m2;
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.skinWeights[nowVertexID].y = nowVal;
break;
case 2:
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.skinIndices[nowVertexID].z = _m2;
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.skinWeights[nowVertexID].z = nowVal;
break;
case 3:
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.skinIndices[nowVertexID].w = _m2;
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry.skinWeights[nowVertexID].w = nowVal;
break;
}
this.loadingXdata.FrameInfo_Raw[nowFrameName].VertexSetedBoneCount[nowVertexID]++;
}
}
}
}
for (var sk = 0; sk < this.loadingXdata.FrameInfo_Raw[nowFrameName].Materials.length; sk++) {
this.loadingXdata.FrameInfo_Raw[nowFrameName].Materials[sk].skinning = true;
}
mesh = new THREE.SkinnedMesh(bufferGeometry.fromGeometry(this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry), new THREE.MultiMaterial(this.loadingXdata.FrameInfo_Raw[nowFrameName].Materials));
var skeleton = new THREE.Skeleton(putBones);
mesh.add(putBones[0]);
mesh.bind(skeleton);
} else {
mesh = new THREE.Mesh(bufferGeometry.fromGeometry(this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry), new THREE.MultiMaterial(this.loadingXdata.FrameInfo_Raw[nowFrameName].Materials));
}
mesh.name = nowFrameName;
this.loadingXdata.FrameInfo_Raw[nowFrameName].Mesh = mesh;
this.loadingXdata.FrameInfo_Raw[nowFrameName].Geometry = null;
}
}
}, {
key: 'animationFinalize',
value: function animationFinalize() {
this.animeKeyNames = Object.keys(this.loadingXdata.AnimationSetInfo);
if (this.animeKeyNames != null && this.animeKeyNames.length > 0) {
this.nowReaded = 0;
this.loadingXdata.XAnimationObj = [];
this.animationFinalize_step();
} else {
this.finalproc();
}
}
}, {
key: 'animationFinalize_step',
value: function animationFinalize_step() {
var i = this.nowReaded;
var keys = Object.keys(this.loadingXdata.FrameInfo_Raw);
var tgtModel = null;
for (var m = 0; m < this.loadingXdata.FrameInfo.length; m++) {
var keys2 = Object.keys(this.loadingXdata.AnimationSetInfo[this.animeKeyNames[i]]);
if (this.loadingXdata.AnimationSetInfo[this.animeKeyNames[i]][keys2[0]].boneName == this.loadingXdata.FrameInfo[m].name) {
tgtModel = this.loadingXdata.FrameInfo[m];
}
}
if (tgtModel != null) {
this.loadingXdata.XAnimationObj[i] = new XAnimationObj();
this.loadingXdata.XAnimationObj[i].fps = this.loadingXdata.AnimTicksPerSecond;
this.loadingXdata.XAnimationObj[i].name = this.animeKeyNames[i];
this.loadingXdata.XAnimationObj[i].make(this.loadingXdata.AnimationSetInfo[this.animeKeyNames[i]], tgtModel);
}
this.nowReaded++;
if (this.nowReaded >= this.animeKeyNames.length) {
this.loadingXdata.AnimationSetInfo = null;
this.finalproc();
} else {
this.animationFinalize_step();
}
}
}, {
key: 'finalproc',
value: function finalproc() {
var _this3 = this;
setTimeout(function () {
_this3.onLoad(_this3.loadingXdata);
}, 1);
}
}]);
return XLoader;
}();
THREE.XLoader.IsUvYReverse = true;
......@@ -25,7 +25,7 @@ THREE.DaydreamController = function () {
var gamepad = gamepads[ i ];
if ( gamepad !== null && ( gamepad.id === 'Daydream Controller' ) ) {
if ( gamepad && ( gamepad.id === 'Daydream Controller' ) ) {
return gamepad;
......@@ -66,7 +66,7 @@ THREE.DaydreamController = function () {
// angular velocity
if ( pose.angularVelocity !== null || ! angularVelocity.equals( pose.angularVelocity ) ) {
if ( pose.angularVelocity !== null && ! angularVelocity.equals( pose.angularVelocity ) ) {
angularVelocity.fromArray( pose.angularVelocity );
scope.dispatchEvent( { type: 'angularvelocitychanged', angularVelocity: angularVelocity } );
......
......@@ -18,6 +18,24 @@ var WEBVR = {
},
getVRDisplay: function ( onDisplay ) {
if ( 'getVRDisplays' in navigator ) {
navigator.getVRDisplays()
.then( function ( displays ) {
onDisplay( displays[ 0 ] );
} )
.catch( function () {
// no displays
} );
}
},
getMessage: function () {
var message;
......@@ -65,7 +83,16 @@ var WEBVR = {
},
getButton: function ( effect ) {
getButton: function ( display, canvas ) {
/*
if ( display instanceof VRDisplay === false ) {
console.error( 'WebVR.getButton() now expects a VRDisplay.' );
return;
}
*/
var button = document.createElement( 'button' );
button.style.position = 'absolute';
......@@ -85,13 +112,13 @@ var WEBVR = {
button.textContent = 'ENTER VR';
button.onclick = function () {
effect.isPresenting ? effect.exitPresent() : effect.requestPresent();
display.isPresenting ? display.exitPresent() : display.requestPresent( [ { source: canvas } ] );
};
window.addEventListener( 'vrdisplaypresentchange', function () {
button.textContent = effect.isPresenting ? 'EXIT VR' : 'ENTER VR';
button.textContent = display.isPresenting ? 'EXIT VR' : 'ENTER VR';
}, false );
......
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.WebVRCamera = function ( display, renderer ) {
var scope = this;
var frameData = null;
if ( 'VRFrameData' in window ) {
frameData = new window.VRFrameData();
}
var eyeTranslationL = new THREE.Vector3();
var eyeTranslationR = new THREE.Vector3();
var cameraL = new THREE.PerspectiveCamera();
cameraL.bounds = new THREE.Vector4( 0.0, 0.0, 0.5, 1.0 );
cameraL.layers.enable( 1 );
var cameraR = new THREE.PerspectiveCamera();
cameraR.bounds = new THREE.Vector4( 0.5, 0.0, 0.5, 1.0 );
cameraR.layers.enable( 2 );
//
var currentSize, currentPixelRatio;
function onVRDisplayPresentChange() {
if ( display.isPresenting ) {
var eyeParameters = display.getEyeParameters( 'left' );
var renderWidth = eyeParameters.renderWidth;
var renderHeight = eyeParameters.renderHeight;
currentPixelRatio = renderer.getPixelRatio();
currentSize = renderer.getSize();
renderer.setPixelRatio( 1 );
renderer.setSize( renderWidth * 2, renderHeight, false );
scope.enabled = true;
} else if ( scope.enabled ) {
scope.enabled = false;
renderer.setPixelRatio( currentPixelRatio );
renderer.setSize( currentSize.width, currentSize.height, true );
}
}
window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
//
THREE.ArrayCamera.call( this, [ cameraL, cameraR ] );
//
this.onBeforeRender = function () {
display.depthNear = scope.near;
display.depthFar = scope.far;
display.getFrameData( frameData );
//
var pose = frameData.pose;
if ( pose.orientation !== null ) {
scope.quaternion.fromArray( pose.orientation );
}
if ( pose.position !== null ) {
scope.position.fromArray( pose.position );
} else {
scope.position.set( 0, 0, 0 );
}
//
var eyeParamsL = display.getEyeParameters( 'left' );
var eyeParamsR = display.getEyeParameters( 'right' );
eyeTranslationL.fromArray( eyeParamsL.offset );
eyeTranslationR.fromArray( eyeParamsR.offset );
cameraL.position.copy( scope.position );
cameraL.quaternion.copy( scope.quaternion );
cameraL.scale.copy( scope.scale );
cameraR.position.copy( scope.position );
cameraR.quaternion.copy( scope.quaternion );
cameraR.scale.copy( scope.scale );
cameraL.translateOnAxis( eyeTranslationL, cameraL.scale.x );
cameraR.translateOnAxis( eyeTranslationR, cameraR.scale.x );
cameraL.updateMatrixWorld();
cameraL.matrixWorldInverse.getInverse( cameraL.matrixWorld );
cameraR.updateMatrixWorld();
cameraR.matrixWorldInverse.getInverse( cameraR.matrixWorld );
cameraL.projectionMatrix.elements = frameData.leftProjectionMatrix;
cameraR.projectionMatrix.elements = frameData.rightProjectionMatrix;
// HACK @mrdoob
// Ideally we'll merge both projection matrices so we can frustum cull
scope.projectionMatrix.copy( cameraL.projectionMatrix );
//
var layers = display.getLayers();
if ( layers.length ) {
var layer = layers[ 0 ];
if ( layer.leftBounds !== null && layer.leftBounds.length === 4 ) {
cameraL.bounds.fromArray( layer.leftBounds );
}
if ( layer.rightBounds !== null && layer.rightBounds.length === 4 ) {
cameraR.bounds.fromArray( layer.rightBounds );
}
}
};
this.onAfterRender = function () {
if ( display.isPresenting ) display.submitFrame();
};
};
THREE.WebVRCamera.prototype = Object.assign( Object.create( THREE.ArrayCamera.prototype ), {
constructor: THREE.WebVRCamera,
isWebVRCamera: true
} );
因为 它太大了无法显示 source diff 。你可以改为 查看blob
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - glTF</title>
<title>three.js webgl - glTF 1.0</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
......@@ -63,11 +63,10 @@
<body>
<div id="info">
<a href="http://threejs.org" target="_blank">three.js</a> -
<a href="https://github.com/KhronosGroup/glTF" target="_blank">glTF</a> loader
<a href="https://github.com/KhronosGroup/glTF" target="_blank">glTF</a> 1.0 loader
<br>
monster by <a href="http://www.3drt.com/downloads.htm" target="_blank">3drt</a> - COLLADA duck by Sony -
Cesium models by <a href="http://cesiumjs.org/" target="_blank">Cesium</a> -
BoomBox by <a href="https://www.microsoft.com/" target="_blank">Microsoft</a>
Cesium models by <a href="http://cesiumjs.org/" target="_blank">Cesium</a>
</div>
<div id="container"></div>
<div id="controls">
......@@ -96,7 +95,7 @@
</div>
<script src="../build/three.js"></script>
<script src="js/controls/OrbitControls.js"></script>
<script src="js/loaders/GLTF2Loader.js"></script>
<script src="js/loaders/GLTFLoader.js"></script>
<script>
var orbitControls = null;
......@@ -203,7 +202,7 @@
scene.add(ground);
}
loader = new THREE.GLTF2Loader();
loader = new THREE.GLTFLoader();
for (var i = 0; i < extensionSelect.children.length; i++) {
var child = extensionSelect.children[i];
......@@ -382,13 +381,6 @@
addGround:true,
extensions: ["glTF", "glTF-MaterialsCommon", "glTF-Binary"]
},
{
name : "BoomBox (PBR)", url : "./models/gltf/BoomBox/%s/BoomBox.gltf",
cameraPos: new THREE.Vector3(2, 1, 3),
objectRotation: new THREE.Euler(0, Math.PI, 0),
addLights:true,
extensions: ["glTF", "glTF-Binary"]
},
{
name : "Duck", url : "./models/gltf/duck/%s/duck.gltf",
cameraPos: new THREE.Vector3(0, 3, 5),
......
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - glTF 2.0</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: #222222;
margin: 0px;
overflow: hidden;
}
#info {
color: #808080;
position: absolute;
top: 10px;
width: 100%;
text-align: center;
z-index: 100;
display:block;
}
#container {
position: absolute;
top: 0px;
width:100%;
height:100%;
z-index: -1;
}
#controls {
position: absolute;
width: 200px;
bottom: 0px;
left: 0px;
padding: 10px;
background-color: White;
font: 13px "Lucida Grande", Lucida, Verdana, sans-serif;
}
#controls > div {
margin-bottom: 8px;
}
#controls hr {
border: 0px;
height: 1px;
margin-bottom: 10px;
background-color: #bbb;
}
#info a, .button {
color: #f00;
font-weight: bold;
text-decoration: underline;
cursor: pointer
}
</style>
</head>
<body>
<div id="info">
<a href="http://threejs.org" target="_blank">three.js</a> -
<a href="https://github.com/KhronosGroup/glTF" target="_blank">glTF</a> 2.0 loader
<br>
BoomBox by <a href="https://www.microsoft.com/" target="_blank">Microsoft</a>
</div>
<div id="container"></div>
<div id="controls">
<div id="status">Loading...</div>
<hr />
<div>
Model
<select id="scenes_list" size="1" onchange="selectScene();" ondblclick="selectScene();"></select>
</div>
<div>
Camera
<select id="cameras_list" size="1" onchange="selectCamera();" ondblclick="selectCamera();"></select>
</div>
<div>
Animations
<input type="checkbox" checked onclick="toggleAnimations();">Play</input>
</div>
<div>
Extension
<select id="extensions_list" onchange="selectExtension();">
<option value="glTF">None</option>
<option value="glTF-MaterialsCommon">Built-in shaders</option>
<option value="glTF-Binary">Binary</option>
</select>
</div>
</div>
<script src="../build/three.js"></script>
<script src="js/controls/OrbitControls.js"></script>
<script src="js/loaders/GLTF2Loader.js"></script>
<script>
var orbitControls = null;
var container, camera, scene, renderer, loader;
var cameraIndex = 0;
var cameras = [];
var cameraNames = [];
var defaultCamera = null;
var gltf = null;
var mixer = null;
var clock = new THREE.Clock();
function onload() {
window.addEventListener( 'resize', onWindowResize, false );
document.addEventListener( 'keydown', function(e) { onKeyDown(e); }, false );
buildSceneList();
switchScene(0);
animate();
}
function initScene(index) {
container = document.getElementById( 'container' );
scene = new THREE.Scene();
defaultCamera = new THREE.PerspectiveCamera( 45, container.offsetWidth / container.offsetHeight, 1, 20000 );
//defaultCamera.up = new THREE.Vector3( 0, 1, 0 );
scene.add( defaultCamera );
camera = defaultCamera;
var sceneInfo = sceneList[index];
var spot1 = null;
if (sceneInfo.addLights) {
var ambient = new THREE.AmbientLight( 0x222222 );
scene.add( ambient );
var directionalLight = new THREE.DirectionalLight( 0xdddddd );
directionalLight.position.set( 0, 0, 1 ).normalize();
scene.add( directionalLight );
spot1 = new THREE.SpotLight( 0xffffff, 1 );
spot1.position.set( 10, 20, 10 );
spot1.angle = 0.25;
spot1.distance = 1024;
spot1.penumbra = 0.75;
if ( sceneInfo.shadows ) {
spot1.castShadow = true;
spot1.shadow.bias = 0.0001;
spot1.shadow.mapSize.width = 2048;
spot1.shadow.mapSize.height = 2048;
}
scene.add( spot1 );
}
// RENDERER
renderer = new THREE.WebGLRenderer({antialias:true});
renderer.setClearColor( 0x222222 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
if (sceneInfo.shadows) {
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
}
container.appendChild( renderer.domElement );
var ground = null;
if (sceneInfo.addGround) {
var groundMaterial = new THREE.MeshPhongMaterial({
color: 0xFFFFFF,
shading: THREE.SmoothShading
});
ground = new THREE.Mesh( new THREE.PlaneBufferGeometry(512, 512), groundMaterial);
if (sceneInfo.shadows) {
ground.receiveShadow = true;
}
if (sceneInfo.groundPos) {
ground.position.copy(sceneInfo.groundPos);
} else {
ground.position.z = -70;
}
ground.rotation.x = -Math.PI / 2;
scene.add(ground);
}
loader = new THREE.GLTF2Loader();
for (var i = 0; i < extensionSelect.children.length; i++) {
var child = extensionSelect.children[i];
child.disabled = sceneInfo.extensions.indexOf(child.value) === -1;
if (child.disabled && child.selected) {
extensionSelect.value = extension = 'glTF';
}
}
var url = sceneInfo.url;
var r = eval("/" + '\%s' + "/g");
url = url.replace(r, extension);
if (extension === 'glTF-Binary') {
url = url.replace('.gltf', '.glb');
}
var loadStartTime = performance.now();
var status = document.getElementById("status");
status.innerHTML = "Loading...";
loader.load( url, function(data) {
gltf = data;
var object = gltf.scene;
status.innerHTML = "Load time: " + ( performance.now() - loadStartTime ).toFixed( 2 ) + " ms.";
if (sceneInfo.cameraPos)
defaultCamera.position.copy(sceneInfo.cameraPos);
if (sceneInfo.center) {
orbitControls.target.copy(sceneInfo.center);
}
if (sceneInfo.objectPosition) {
object.position.copy(sceneInfo.objectPosition);
if (spot1) {
spot1.position.set(sceneInfo.objectPosition.x - 100, sceneInfo.objectPosition.y + 200, sceneInfo.objectPosition.z - 100 );
spot1.target.position.copy(sceneInfo.objectPosition);
}
}
if (sceneInfo.objectRotation)
object.rotation.copy(sceneInfo.objectRotation);
if (sceneInfo.objectScale)
object.scale.copy(sceneInfo.objectScale);
cameraIndex = 0;
cameras = [];
cameraNames = [];
if (gltf.cameras && gltf.cameras.length) {
var i, len = gltf.cameras.length;
for (i = 0; i < len; i++) {
var addCamera = true;
var cameraName = gltf.cameras[i].parent.name;
if (sceneInfo.cameras && !(cameraName in sceneInfo.cameras)) {
addCamera = false;
}
if (addCamera) {
cameraNames.push(cameraName);
cameras.push(gltf.cameras[i]);
}
}
updateCamerasList();
switchCamera(1);
} else {
updateCamerasList();
switchCamera(0);
}
var animations = gltf.animations;
if ( animations && animations.length ) {
mixer = new THREE.AnimationMixer( object );
for ( var i = 0; i < animations.length; i ++ ) {
var animation = animations[ i ];
// There's .3333 seconds junk at the tail of the Monster animation that
// keeps it from looping cleanly. Clip it at 3 seconds
if ( sceneInfo.animationTime )
animation.duration = sceneInfo.animationTime;
mixer.clipAction( animation ).play();
}
}
scene.add( object );
onWindowResize();
});
orbitControls = new THREE.OrbitControls(defaultCamera, renderer.domElement);
}
function onWindowResize() {
defaultCamera.aspect = container.offsetWidth / container.offsetHeight;
defaultCamera.updateProjectionMatrix();
var i, len = cameras.length;
for (i = 0; i < len; i++) { // just do it for default
cameras[i].aspect = container.offsetWidth / container.offsetHeight;
cameras[i].updateProjectionMatrix();
}
renderer.setSize( window.innerWidth, window.innerHeight );
}
function animate() {
requestAnimationFrame( animate );
if (mixer) mixer.update(clock.getDelta());
if (cameraIndex == 0)
orbitControls.update();
render();
}
function render() {
renderer.render( scene, camera );
}
function onKeyDown(event) {
var chr = String.fromCharCode(event.keyCode);
if (chr == ' ') {
index = cameraIndex + 1;
if (index > cameras.length)
index = 0;
switchCamera(index);
} else {
var index = parseInt(chr);
if (!isNaN(index) && (index <= cameras.length)) {
switchCamera(index);
}
}
}
var sceneList = [
{
name : "BoomBox (PBR)", url : "./models/gltf/BoomBox/%s/BoomBox.gltf",
cameraPos: new THREE.Vector3(2, 1, 3),
objectRotation: new THREE.Euler(0, Math.PI, 0),
addLights:true,
extensions: ["glTF"]
}
];
function buildSceneList() {
var elt = document.getElementById('scenes_list');
while( elt.hasChildNodes() ){
elt.removeChild(elt.lastChild);
}
var i, len = sceneList.length;
for (i = 0; i < len; i++) {
option = document.createElement("option");
option.text=sceneList[i].name;
elt.add(option);
}
}
function switchScene(index) {
cleanup();
initScene(index);
var elt = document.getElementById('scenes_list');
elt.selectedIndex = index;
}
function selectScene() {
var select = document.getElementById("scenes_list");
var index = select.selectedIndex;
if (index >= 0) {
switchScene(index);
}
}
function switchCamera(index) {
cameraIndex = index;
if (cameraIndex == 0) {
camera = defaultCamera;
}
if (cameraIndex >= 1 && cameraIndex <= cameras.length) {
camera = cameras[cameraIndex - 1];
}
var elt = document.getElementById('cameras_list');
elt.selectedIndex = cameraIndex;
}
function updateCamerasList() {
var elt = document.getElementById('cameras_list');
while( elt.hasChildNodes() ){
elt.removeChild(elt.lastChild);
}
option = document.createElement("option");
option.text="[default]";
elt.add(option);
var i, len = cameraNames.length;
for (i = 0; i < len; i++) {
option = document.createElement("option");
option.text=cameraNames[i];
elt.add(option);
}
}
function selectCamera() {
var select = document.getElementById("cameras_list");
var index = select.selectedIndex;
if (index >= 0) {
switchCamera(index);
}
}
function toggleAnimations() {
var i, len = gltf.animations.length;
for (i = 0; i < len; i++) {
var clip = gltf.animations[i];
var action = mixer.existingAction( clip );
if (action.isRunning()) {
action.stop();
} else {
action.play();
}
}
}
var extensionSelect = document.getElementById("extensions_list");
var extension = extensionSelect.value;
function selectExtension()
{
extension = extensionSelect.value;
selectScene();
}
function cleanup() {
if (container && renderer) {
container.removeChild(renderer.domElement);
}
cameraIndex = 0;
cameras = [];
cameraNames = [];
defaultCamera = null;
if (!loader || !mixer)
return;
mixer.stopAllAction();
}
onload();
</script>
</body>
</html>
<!DOCTYPE html>
<html lang='en'>
<head>
<title>three.js webgl - loaders - X-File loader</title>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0'>
<style>
body {
font-family: Monospace;
background-color: #000;
color: #fff;
margin: 0px;
overflow: hidden;
}
#info {
color: #fff;
position: absolute;
top: 10px;
width: 100%;
text-align: center;
z-index: -1;
display: block;
}
#info a,
.button {
color: #f00;
font-weight: bold;
text-decoration: underline;
cursor: pointer;
}
</style>
</head>
<body>
<div id='info'>
<a href='http://threejs.org' target='_blank'>three.js</a> - X-File Loader test<br />
</div>
<script src='../build/three.js'></script>
<script src='js/controls/OrbitControls.js'></script>
<script src='js/loaders/XLoader.js'></script>
<script src='js/Detector.js'></script>
<script src='js/libs/stats.min.js'></script>
<script src='js/libs/dat.gui.min.js'></script>
<script>
if (!Detector.webgl) Detector.addGetWebGLMessage();
var container, stats, controls;
var camera, scene, renderer;
var clock = new THREE.Clock();
var gui = new dat.GUI();
var mixers = [];
var manager = null;
var Texloader = null;
var ParentList = null;
var skeletonHelper = null;
var Models = [];
var animateInf = null;
var DashAnime = null;
var d = new Date();
var LastDateTime = null;
var animates = [];
var actions = [];
init();
function init() {
LastDateTime = Date.now();
container = document.createElement('div');
document.body.appendChild(container);
container.style.zIndex = -10;
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 2000);
scene = new THREE.Scene();
scene.add(new THREE.AmbientLight(0x999999));
// grid
var gridHelper = new THREE.GridHelper(14, 1, 0x303030, 0x303030);
gridHelper.position.set(0, -0.04, 0);
scene.add(gridHelper);
// stats
stats = new Stats();
container.appendChild(stats.dom);
// model
manager = new THREE.LoadingManager();
manager.onProgress = function (item, loaded, total) {
console.log(item, loaded, total);
};
var onProgress = function (xhr) {
if (xhr.lengthComputable) {
var percentComplete = xhr.loaded / xhr.total * 100;
console.log(Math.round(percentComplete, 2) + '% downloaded');
}
};
var onError = function (xhr) {
console.log('Errror Loading!');
};
Texloader = new THREE.TextureLoader();
var loader = new THREE.XLoader(manager, Texloader);
// ! If [ Texture ] was reversed Y axis, enable the following.
// THREE.XLoader.IsUvYReverse = false;
// ! And if [ Model ] was reversed X axis, enable the following.
// loader.load([' your model url ', false ], function (object) {
// read (download) model file
loader.load(['models/xfile/SSR06_Born2.x', true], function (object) {
for (var i = 0; i < object.FrameInfo.length; i++) {
Models.push(object.FrameInfo[i]);
scene.add(Models[i]);
if (Models[i] instanceof THREE.SkinnedMesh) {
skeletonHelper = new THREE.SkeletonHelper(Models[i]);
scene.add(skeletonHelper);
if (object.XAnimationObj !== undefined && object.XAnimationObj.length !== 0) {
Models[i].geometry.animations = [];
/*
* ↓ that is BASIC animation data code.
* Usually, please use this.
* Because of the data I have, I use a different code
*
for (var a = 0; a < object.XAnimationObj.length; a++) {
Models[i].geometry.animations.push(THREE.AnimationClip.parseAnimation(object.XAnimationObj[a], Models[i].skeleton.bones));
}
Models[i].mixer = new THREE.AnimationMixer(Models[i]);
animates.push(Models[i].mixer);
var action = Models[i].mixer.clipAction(Models[i].geometry.animations[0]);
action.play();
*/
// ↓ that is a code for [ All animation-keyframes are connected data ]. output from 'LightWave3D'
{
Models[i].geometry.animations.push(THREE.AnimationClip.parseAnimation(splitAnimation(object.XAnimationObj[0], 'stand', 10 * object.XAnimationObj[0].fps, 11 * object.XAnimationObj[0].fps), Models[i].skeleton.bones));
Models[i].geometry.animations.push(THREE.AnimationClip.parseAnimation(splitAnimation(object.XAnimationObj[0], 'walk', 50 * object.XAnimationObj[0].fps, 80 * object.XAnimationObj[0].fps), Models[i].skeleton.bones));
Models[i].geometry.animations.push(THREE.AnimationClip.parseAnimation(splitAnimation(object.XAnimationObj[0], 'dash', 140 * object.XAnimationObj[0].fps, 160 * object.XAnimationObj[0].fps), Models[i].skeleton.bones));
Models[i].geometry.animations.push(THREE.AnimationClip.parseAnimation(splitAnimation(object.XAnimationObj[0], 'dashing', 160 * object.XAnimationObj[0].fps, 165 * object.XAnimationObj[0].fps), Models[i].skeleton.bones));
Models[i].geometry.animations.push(THREE.AnimationClip.parseAnimation(splitAnimation(object.XAnimationObj[0], 'damage', 500 * object.XAnimationObj[0].fps, 530 * object.XAnimationObj[0].fps), Models[i].skeleton.bones));
Models[i].mixer = new THREE.AnimationMixer(Models[i]);
animates.push(Models[i].mixer);
var stand = Models[i].mixer.clipAction('stand');
// stand.play();
stand.setLoop(THREE.LoopRepeat);
actions['stand'] = stand;
var walk = Models[i].mixer.clipAction('walk');
walk.setLoop(THREE.LoopRepeat);
walk.play();
actions['walk'] = walk;
var dash = Models[i].mixer.clipAction('dash');
dash.setLoop(THREE.LoopOnce);
//dash.play();
actions['dash'] = dash;
var dashing = Models[i].mixer.clipAction('dashing');
dashing.setLoop(THREE.LoopPingPong);
// dashing.play();
actions['dashing'] = dashing;
var damage = Models[i].mixer.clipAction('damage');
damage.setLoop(THREE.LoopRepeat);
//damage.play();
actions['damage'] = damage;
var ActionKeys = Object.keys(actions);
var dmy = {};
dmy.gui = '';
dmy.action = '';
gui.add(dmy, 'action', ActionKeys).onChange(function (v) {
animates[0].stopAllAction();
actions[v].play();
});
}
///////////
}
}
}
object = null;
}, onProgress, onError);
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x666666);
container.appendChild(renderer.domElement);
controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.target.set(0, 12, 0);
camera.position.set(2, 18, 28);
camera.up.set(0, 1, 0);
var light = new THREE.DirectionalLight(0xeeeeff, 2);
light.position.set(10, 100, 1).normalize();
scene.add(light);
light = new THREE.DirectionalLight(0xaa5555);
light.position.set(-1, -1, -1).normalize();
scene.add(light);
controls.update();
window.addEventListener('resize', onWindowResize, false);
animate();
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
//
function animate() {
requestAnimationFrame(animate);
var nowTime = Date.now();
var dulTime = nowTime - LastDateTime;
LastDateTime = nowTime;
if (animates != null && animates.length > 0) {
for (var i = 0; i < animates.length; i++) {
animates[i].update(dulTime);
}
}
if (Models != null && Models.length > 0 && skeletonHelper != null) { skeletonHelper.update(); }
stats.update();
render();
}
function render() {
renderer.render(scene, camera);
}
/////////////////
/// this is not must mount codes.
// split One and Long Animation, for time
function splitAnimation(_baseAnime, _name, _beginTime, _endTime) {
var Animation = {};
Animation.fps = _baseAnime.fps;
Animation.name = _name;
Animation.length = _endTime - _beginTime;
Animation.hierarchy = [];
for (var i = 0; i < _baseAnime.hierarchy.length; i++) {
var firstKey = -1;
var lastKey = -1;
var frame = {};
frame.name = _baseAnime.hierarchy[i].name;
frame.parent = _baseAnime.hierarchy[i].parent;
frame.keys = [];
for (var m = 1; m < _baseAnime.hierarchy[i].keys.length; m++) {
if (_baseAnime.hierarchy[i].keys[m].time > _beginTime) {
if (firstKey === -1) {
firstKey = m - 1;
frame.keys.push(_baseAnime.hierarchy[i].keys[m - 1]);
}
frame.keys.push(_baseAnime.hierarchy[i].keys[m]);
}
if (_endTime <= _baseAnime.hierarchy[i].keys[m].time || m >= _baseAnime.hierarchy[i].keys.length - 1) {
break;
}
}
for (var m = 0; m < frame.keys.length; m++) {
frame.keys[m].time -= _beginTime;
}
Animation.hierarchy.push(frame);
}
return Animation;
}
</script>
</body>
</html>
\ No newline at end of file
......@@ -4,8 +4,8 @@
<title>three.js webvr - daydream</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<!-- Origin Trial Token, feature = WebVR, origin = https://threejs.org, expires = 2017-03-13 -->
<meta http-equiv="origin-trial" data-feature="WebVR" data-expires="2017-03-13" content="Any7HFKv+fkg+mBnJBBFIYyFbQgDyum3bNsVUXBInRDadbhafI6F0hXq/cStNqdi29167TYlkDuH/JE5ZZSI6gcAAABKeyJvcmlnaW4iOiJodHRwczovL3RocmVlanMub3JnOjQ0MyIsImZlYXR1cmUiOiJXZWJWUiIsImV4cGlyeSI6MTQ4OTQxNzU2OX0=">
<!-- Origin Trial Token, feature = WebVR, origin = https://threejs.org, expires = 2017-04-17 -->
<meta http-equiv="origin-trial" data-feature="WebVR" data-expires="2017-04-17" content="Aj3fKurj0eOvRSbpJ0NaqkV/AE2Y2KJIepdCGWNmCB/iMgbDV/rhFn8zFu6c6zZZlRGZNR7Xv/BEX544EeqLuQAAAABKeyJvcmlnaW4iOiJodHRwczovL3RocmVlanMub3JnOjQ0MyIsImZlYXR1cmUiOiJXZWJWUiIsImV4cGlyeSI6MTQ5MjQ3MzYwMH0=">
<style>
body {
font-family: Monospace;
......@@ -23,10 +23,9 @@
<script src="../build/three.js"></script>
<script src="js/controls/VRControls.js"></script>
<script src="js/effects/VREffect.js"></script>
<script src="js/vr/DaydreamController.js"></script>
<script src="js/vr/WebVR.js"></script>
<script src="js/vr/WebVRCamera.js"></script>
<script>
......@@ -42,7 +41,7 @@
var container;
var camera, scene, ray, raycaster, renderer;
var effect, controls, gamepad;
var gamepad, vrdisplay;
var room;
......@@ -67,7 +66,6 @@
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.1, 10 );
scene.add( camera );
room = new THREE.Mesh(
new THREE.BoxGeometry( 6, 6, 6, 8, 8, 8 ),
......@@ -123,23 +121,15 @@
//
controls = new THREE.VRControls( camera );
effect = new THREE.VREffect( renderer );
WEBVR.getVRDisplay( function ( display ) {
if ( navigator.getVRDisplays ) {
vrdisplay = display;
navigator.getVRDisplays()
.then( function ( displays ) {
effect.setVRDisplay( displays[ 0 ] );
controls.setVRDisplay( displays[ 0 ] );
} )
.catch( function () {
// no displays
} );
camera = new THREE.WebVRCamera( display, renderer );
document.body.appendChild( WEBVR.getButton( effect ) );
document.body.appendChild( WEBVR.getButton( display, renderer.domElement ) );
}
} );
//
......@@ -164,7 +154,7 @@
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
effect.setSize( window.innerWidth, window.innerHeight );
renderer.setSize( window.innerWidth, window.innerHeight );
}
......@@ -172,9 +162,10 @@
function animate() {
effect.requestAnimationFrame( animate );
render();
gamepad.update();
render();
( vrdisplay ? vrdisplay : window ).requestAnimationFrame( animate );
}
......@@ -246,8 +237,7 @@
}
controls.update();
effect.render( scene, camera );
renderer.render( scene, camera );
}
......
......@@ -61,6 +61,7 @@ export { StereoCamera } from './cameras/StereoCamera.js';
export { PerspectiveCamera } from './cameras/PerspectiveCamera.js';
export { OrthographicCamera } from './cameras/OrthographicCamera.js';
export { CubeCamera } from './cameras/CubeCamera.js';
export { ArrayCamera } from './cameras/ArrayCamera.js';
export { Camera } from './cameras/Camera.js';
export { AudioListener } from './audio/AudioListener.js';
export { PositionalAudio } from './audio/PositionalAudio.js';
......
/**
* @author mrdoob / http://mrdoob.com/
*/
import { PerspectiveCamera } from './PerspectiveCamera';
function ArrayCamera( array ) {
PerspectiveCamera.call( this );
this.enabled = false;
this.cameras = array || [];
}
ArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), {
constructor: ArrayCamera,
isArrayCamera: true
} );
export { ArrayCamera };
import { Matrix4 } from '../math/Matrix4';
import { Quaternion } from '../math/Quaternion';
import { Object3D } from '../core/Object3D';
import { Vector3 } from '../math/Vector3';
/**
* @author mrdoob / http://mrdoob.com/
* @author mikael emtinger / http://gomo.se/
* @author WestLangley / http://github.com/WestLangley
*/
import { Matrix4 } from '../math/Matrix4';
import { Quaternion } from '../math/Quaternion';
import { Object3D } from '../core/Object3D';
import { Vector3 } from '../math/Vector3';
function Camera() {
Object3D.call( this );
......@@ -20,43 +20,45 @@ function Camera() {
}
Camera.prototype = Object.create( Object3D.prototype );
Camera.prototype.constructor = Camera;
Camera.prototype = Object.assign( Object.create( Object3D.prototype ), {
constructor: Camera,
Camera.prototype.isCamera = true;
isCamera: true,
Camera.prototype.getWorldDirection = function () {
copy: function ( source ) {
var quaternion = new Quaternion();
Object3D.prototype.copy.call( this, source );
return function getWorldDirection( optionalTarget ) {
this.matrixWorldInverse.copy( source.matrixWorldInverse );
this.projectionMatrix.copy( source.projectionMatrix );
var result = optionalTarget || new Vector3();
return this;
this.getWorldQuaternion( quaternion );
},
return result.set( 0, 0, - 1 ).applyQuaternion( quaternion );
getWorldDirection: function () {
};
var quaternion = new Quaternion();
}();
return function getWorldDirection( optionalTarget ) {
Camera.prototype.clone = function () {
var result = optionalTarget || new Vector3();
return new this.constructor().copy( this );
this.getWorldQuaternion( quaternion );
};
return result.set( 0, 0, - 1 ).applyQuaternion( quaternion );
Camera.prototype.copy = function ( source ) {
};
Object3D.prototype.copy.call( this, source );
}(),
this.matrixWorldInverse.copy( source.matrixWorldInverse );
this.projectionMatrix.copy( source.projectionMatrix );
clone: function () {
return this;
return new this.constructor().copy( this );
};
}
} );
export { Camera };
......@@ -161,7 +161,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
},
clearViewOffset: function() {
clearViewOffset: function () {
this.view = null;
this.updateProjectionMatrix();
......
......@@ -47,6 +47,7 @@ Object.assign( Clock.prototype, {
if ( this.autoStart && ! this.running ) {
this.start();
return 0;
}
......
......@@ -1060,6 +1060,8 @@ function WebGLRenderer( parameters ) {
// update camera matrices and frustum
camera.onBeforeRender( _this );
if ( camera.parent === null ) camera.updateMatrixWorld();
camera.matrixWorldInverse.getInverse( camera.matrixWorld );
......@@ -1208,6 +1210,7 @@ function WebGLRenderer( parameters ) {
// opaque pass (front-to-back order)
state.setBlending( NoBlending );
if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera );
// transparent pass (back-to-front order)
......@@ -1235,6 +1238,14 @@ function WebGLRenderer( parameters ) {
state.buffers.depth.setMask( true );
state.buffers.color.setMask( true );
if ( camera.isArrayCamera && camera.enabled ) {
_this.setScissorTest( false );
}
camera.onAfterRender( _this );
// _gl.finish();
};
......@@ -1401,22 +1412,30 @@ function WebGLRenderer( parameters ) {
object.onBeforeRender( _this, scene, camera, geometry, material, group );
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
if ( object.isImmediateRenderObject ) {
if ( camera.isArrayCamera && camera.enabled ) {
state.setMaterial( material );
var cameras = camera.cameras;
var program = setProgram( camera, scene.fog, material, object );
for ( var j = 0, jl = cameras.length; j < jl; j ++ ) {
_currentGeometryProgram = '';
var camera2 = cameras[ j ];
var bounds = camera2.bounds;
_this.setViewport(
bounds.x * _width * _pixelRatio, bounds.y * _height * _pixelRatio,
bounds.z * _width * _pixelRatio, bounds.w * _height * _pixelRatio
);
_this.setScissor(
bounds.x * _width * _pixelRatio, bounds.y * _height * _pixelRatio,
bounds.z * _width * _pixelRatio, bounds.w * _height * _pixelRatio
);
_this.setScissorTest( true );
renderObject( object, scene, camera2, geometry, material, group );
renderObjectImmediate( object, program, material );
}
} else {
_this.renderBufferDirect( camera, scene.fog, geometry, material, object, group );
renderObject( object, scene, camera, geometry, material, group );
}
......@@ -1426,6 +1445,29 @@ function WebGLRenderer( parameters ) {
}
function renderObject( object, scene, camera, geometry, material, group ) {
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
if ( object.isImmediateRenderObject ) {
state.setMaterial( material );
var program = setProgram( camera, scene.fog, material, object );
_currentGeometryProgram = '';
renderObjectImmediate( object, program, material );
} else {
_this.renderBufferDirect( camera, scene.fog, geometry, material, object, group );
}
}
function initMaterial( material, fog, object ) {
var materialProperties = properties.get( material );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册