diff --git a/examples/jsm/tsl/display/DepthOfFieldNode.js b/examples/jsm/tsl/display/DepthOfFieldNode.js index bdc0811db3ad92..396cbbca7b407e 100644 --- a/examples/jsm/tsl/display/DepthOfFieldNode.js +++ b/examples/jsm/tsl/display/DepthOfFieldNode.js @@ -190,6 +190,14 @@ class DepthOfFieldNode extends TempNode { */ this._CoCTextureNode = texture( this._CoCRT.texture ); + /** + * The Gaussian blur node used to blur the near field's circle of confusion. + * + * @private + * @type {GaussianBlurNode} + */ + this._CoCBlurNode = gaussianBlur( this._CoCTextureNode, 1, 2 ); + /** * The result of the blur64 pass as a texture node. * @@ -381,7 +389,7 @@ class DepthOfFieldNode extends TempNode { // blurred CoC for near field - this._CoCBlurredMaterial.colorNode = gaussianBlur( this._CoCTextureNode, 1, 2 ); + this._CoCBlurredMaterial.colorNode = this._CoCBlurNode; this._CoCBlurredMaterial.needsUpdate = true; // bokeh 64 blur pass @@ -539,6 +547,8 @@ class DepthOfFieldNode extends TempNode { this._blur16Material.dispose(); this._compositeMaterial.dispose(); + this._CoCBlurNode.dispose(); + } } diff --git a/src/core/BufferAttribute.js b/src/core/BufferAttribute.js index 79f8ae7cb4562d..958fb453e027ae 100644 --- a/src/core/BufferAttribute.js +++ b/src/core/BufferAttribute.js @@ -670,9 +670,9 @@ class BufferAttribute extends EventDispatcher { normalized: this.normalized }; - if ( this.name !== '' ) data.name = this.name; - if ( this.usage !== StaticDrawUsage ) data.usage = this.usage; - if ( this.gpuType !== FloatType ) data.gpuType = this.gpuType; + data.name = this.name; + data.usage = this.usage; + data.gpuType = this.gpuType; return data; diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index 76e2f59ff2b334..db7bfe67f8b159 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -1241,7 +1241,7 @@ class BufferGeometry extends EventDispatcher { data.uuid = this.uuid; data.type = ( this.parameters !== undefined && this._transformed === true ) ? 'BufferGeometry' : this.type; - if ( this.name !== '' ) data.name = this.name; + data.name = this.name; if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData; if ( this.parameters !== undefined && this._transformed !== true ) { diff --git a/src/core/InterleavedBuffer.js b/src/core/InterleavedBuffer.js index 7b0b1391f6cad0..d74d26e5f2dd1a 100644 --- a/src/core/InterleavedBuffer.js +++ b/src/core/InterleavedBuffer.js @@ -284,7 +284,7 @@ class InterleavedBuffer { stride: this.stride }; - if ( this.usage !== StaticDrawUsage ) json.usage = this.usage; + json.usage = this.usage; return json; diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 42c9888d22a97c..a0a09156f7e781 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -1320,13 +1320,15 @@ class Object3D extends EventDispatcher { object.uuid = this.uuid; object.type = this.type; - if ( this.name !== '' ) object.name = this.name; - if ( this.castShadow === true ) object.castShadow = true; - if ( this.receiveShadow === true ) object.receiveShadow = true; - if ( this.visible === false ) object.visible = false; - if ( this.frustumCulled === false ) object.frustumCulled = false; - if ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder; - if ( this.static !== false ) object.static = this.static; + object.name = this.name; + object.castShadow = this.castShadow; + object.receiveShadow = this.receiveShadow; + object.visible = this.visible; + object.frustumCulled = this.frustumCulled; + object.renderOrder = this.renderOrder; + object.static = this.static; + object.matrixAutoUpdate = this.matrixAutoUpdate; + if ( Object.keys( this.userData ).length > 0 ) object.userData = this.userData; object.layers = this.layers.mask; @@ -1335,8 +1337,6 @@ class Object3D extends EventDispatcher { if ( this.pivot !== null ) object.pivot = this.pivot.toArray(); - if ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false; - if ( this.morphTargetDictionary !== undefined ) object.morphTargetDictionary = Object.assign( {}, this.morphTargetDictionary ); if ( this.morphTargetInfluences !== undefined ) object.morphTargetInfluences = this.morphTargetInfluences.slice(); diff --git a/src/lights/LightShadow.js b/src/lights/LightShadow.js index 88b7d3b22bc844..cf98b66cfc4c65 100644 --- a/src/lights/LightShadow.js +++ b/src/lights/LightShadow.js @@ -329,12 +329,12 @@ class LightShadow { const object = {}; - if ( this.intensity !== 1 ) object.intensity = this.intensity; - if ( this.bias !== 0 ) object.bias = this.bias; - if ( this.normalBias !== 0 ) object.normalBias = this.normalBias; - if ( this.radius !== 1 ) object.radius = this.radius; - if ( this.blurSamples !== 8 ) object.blurSamples = this.blurSamples; - if ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray(); + object.intensity = this.intensity; + object.bias = this.bias; + object.normalBias = this.normalBias; + object.radius = this.radius; + object.blurSamples = this.blurSamples; + object.mapSize = this.mapSize.toArray(); object.camera = this.camera.toJSON( false ).object; delete object.camera.matrix; diff --git a/src/lights/SpotLightShadow.js b/src/lights/SpotLightShadow.js index d7a5801b0f1fb8..d1236f640f61e8 100644 --- a/src/lights/SpotLightShadow.js +++ b/src/lights/SpotLightShadow.js @@ -86,8 +86,8 @@ class SpotLightShadow extends LightShadow { const object = super.toJSON(); - if ( this.focus !== 1 ) object.focus = this.focus; - if ( this.aspect !== 1 ) object.aspect = this.aspect; + object.focus = this.focus; + object.aspect = this.aspect; return object; diff --git a/src/materials/Material.js b/src/materials/Material.js index 060a4e67fb26b4..fe5bca948033d5 100644 --- a/src/materials/Material.js +++ b/src/materials/Material.js @@ -1,6 +1,6 @@ import { Color } from '../math/Color.js'; import { EventDispatcher } from '../core/EventDispatcher.js'; -import { FrontSide, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp, BasicDepthPacking } from '../constants.js'; +import { FrontSide, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js'; import { generateUUID } from '../math/MathUtils.js'; import { warn } from '../utils.js'; import { Vector2 } from '../math/Vector2.js'; @@ -629,10 +629,61 @@ class Material extends EventDispatcher { }; // standard Material serialization + data.uuid = this.uuid; data.type = this.type; - if ( this.name !== '' ) data.name = this.name; + data.blending = this.blending; + data.side = this.side; + data.shadowSide = this.shadowSide; + data.vertexColors = this.vertexColors; + + data.opacity = this.opacity; + data.transparent = this.transparent; + + data.blendSrc = this.blendSrc; + data.blendDst = this.blendDst; + data.blendEquation = this.blendEquation; + data.blendSrcAlpha = this.blendSrcAlpha; + data.blendDstAlpha = this.blendDstAlpha; + data.blendEquationAlpha = this.blendEquationAlpha; + data.blendColor = this.blendColor.getHex(); + data.blendAlpha = this.blendAlpha; + + data.depthFunc = this.depthFunc; + data.depthTest = this.depthTest; + data.depthWrite = this.depthWrite; + data.colorWrite = this.colorWrite; + + data.clipIntersection = this.clipIntersection; + data.clipShadows = this.clipShadows; + + data.stencilWriteMask = this.stencilWriteMask; + data.stencilFunc = this.stencilFunc; + data.stencilRef = this.stencilRef; + data.stencilFuncMask = this.stencilFuncMask; + data.stencilFail = this.stencilFail; + data.stencilZFail = this.stencilZFail; + data.stencilZPass = this.stencilZPass; + data.stencilWrite = this.stencilWrite; + + data.polygonOffset = this.polygonOffset; + data.polygonOffsetFactor = this.polygonOffsetFactor; + data.polygonOffsetUnits = this.polygonOffsetUnits; + + data.dithering = this.dithering; + + data.alphaTest = this.alphaTest; + data.alphaHash = this.alphaHash; + data.alphaToCoverage = this.alphaToCoverage; + data.premultipliedAlpha = this.premultipliedAlpha; + data.forceSinglePass = this.forceSinglePass; + data.allowOverride = this.allowOverride; + + data.visible = this.visible; + data.toneMapped = this.toneMapped; + + data.name = this.name; if ( this.color && this.color.isColor ) data.color = this.color.getHex(); @@ -643,7 +694,7 @@ class Material extends EventDispatcher { if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex(); if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness; if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex(); - if ( this.emissiveIntensity !== undefined && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity; + if ( this.emissiveIntensity !== undefined ) data.emissiveIntensity = this.emissiveIntensity; if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex(); if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity; @@ -783,90 +834,39 @@ class Material extends EventDispatcher { if ( this.transmissionMap && this.transmissionMap.isTexture ) data.transmissionMap = this.transmissionMap.toJSON( meta ).uuid; if ( this.thickness !== undefined ) data.thickness = this.thickness; if ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid; - if ( this.attenuationDistance !== undefined && this.attenuationDistance !== Infinity ) data.attenuationDistance = this.attenuationDistance; + if ( this.attenuationDistance !== undefined ) data.attenuationDistance = this.attenuationDistance; if ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex(); if ( this.size !== undefined ) data.size = this.size; - if ( this.shadowSide !== null ) data.shadowSide = this.shadowSide; if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation; - if ( this.blending !== NormalBlending ) data.blending = this.blending; - if ( this.side !== FrontSide ) data.side = this.side; - if ( this.vertexColors === true ) data.vertexColors = true; - - if ( this.opacity < 1 ) data.opacity = this.opacity; - if ( this.transparent === true ) data.transparent = true; - - if ( this.blendSrc !== SrcAlphaFactor ) data.blendSrc = this.blendSrc; - if ( this.blendDst !== OneMinusSrcAlphaFactor ) data.blendDst = this.blendDst; - if ( this.blendEquation !== AddEquation ) data.blendEquation = this.blendEquation; - if ( this.blendSrcAlpha !== null ) data.blendSrcAlpha = this.blendSrcAlpha; - if ( this.blendDstAlpha !== null ) data.blendDstAlpha = this.blendDstAlpha; - if ( this.blendEquationAlpha !== null ) data.blendEquationAlpha = this.blendEquationAlpha; - if ( this.blendColor && this.blendColor.isColor ) data.blendColor = this.blendColor.getHex(); - if ( this.blendAlpha !== 0 ) data.blendAlpha = this.blendAlpha; - - if ( this.depthFunc !== LessEqualDepth ) data.depthFunc = this.depthFunc; - if ( this.depthTest === false ) data.depthTest = this.depthTest; - if ( this.depthWrite === false ) data.depthWrite = this.depthWrite; - if ( this.colorWrite === false ) data.colorWrite = this.colorWrite; - if ( Array.isArray( this.clippingPlanes ) && this.clippingPlanes.length > 0 ) { data.clippingPlanes = this.clippingPlanes.map( plane => plane.toJSON() ); } - if ( this.clipIntersection === true ) data.clipIntersection = true; - if ( this.clipShadows === true ) data.clipShadows = true; - - if ( this.stencilWriteMask !== 0xff ) data.stencilWriteMask = this.stencilWriteMask; - if ( this.stencilFunc !== AlwaysStencilFunc ) data.stencilFunc = this.stencilFunc; - if ( this.stencilRef !== 0 ) data.stencilRef = this.stencilRef; - if ( this.stencilFuncMask !== 0xff ) data.stencilFuncMask = this.stencilFuncMask; - if ( this.stencilFail !== KeepStencilOp ) data.stencilFail = this.stencilFail; - if ( this.stencilZFail !== KeepStencilOp ) data.stencilZFail = this.stencilZFail; - if ( this.stencilZPass !== KeepStencilOp ) data.stencilZPass = this.stencilZPass; - if ( this.stencilWrite === true ) data.stencilWrite = this.stencilWrite; - // rotation (SpriteMaterial) - if ( this.rotation !== undefined && this.rotation !== 0 ) data.rotation = this.rotation; + if ( this.rotation !== undefined ) data.rotation = this.rotation; // depthPacking (MeshDepthMaterial) - if ( this.depthPacking !== undefined && this.depthPacking !== BasicDepthPacking ) data.depthPacking = this.depthPacking; - - if ( this.polygonOffset === true ) data.polygonOffset = true; - if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor; - if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits; + if ( this.depthPacking !== undefined ) data.depthPacking = this.depthPacking; - if ( this.linewidth !== undefined && this.linewidth !== 1 ) data.linewidth = this.linewidth; - if ( this.linecap !== undefined && this.linecap !== 'round' ) data.linecap = this.linecap; - if ( this.linejoin !== undefined && this.linejoin !== 'round' ) data.linejoin = this.linejoin; + if ( this.linewidth !== undefined ) data.linewidth = this.linewidth; + if ( this.linecap !== undefined ) data.linecap = this.linecap; + if ( this.linejoin !== undefined ) data.linejoin = this.linejoin; if ( this.dashSize !== undefined ) data.dashSize = this.dashSize; if ( this.gapSize !== undefined ) data.gapSize = this.gapSize; if ( this.scale !== undefined ) data.scale = this.scale; - if ( this.dithering === true ) data.dithering = true; - - if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest; - if ( this.alphaHash === true ) data.alphaHash = true; - if ( this.alphaToCoverage === true ) data.alphaToCoverage = true; - if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true; - if ( this.forceSinglePass === true ) data.forceSinglePass = true; - if ( this.allowOverride === false ) data.allowOverride = false; - - if ( this.wireframe === true ) data.wireframe = true; - if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth; - if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap; - if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin; - - if ( this.flatShading === true ) data.flatShading = true; - - if ( this.visible === false ) data.visible = false; + if ( this.wireframe !== undefined ) data.wireframe = this.wireframe; + if ( this.wireframeLinewidth !== undefined ) data.wireframeLinewidth = this.wireframeLinewidth; + if ( this.wireframeLinecap !== undefined ) data.wireframeLinecap = this.wireframeLinecap; + if ( this.wireframeLinejoin !== undefined ) data.wireframeLinejoin = this.wireframeLinejoin; - if ( this.toneMapped === false ) data.toneMapped = false; + if ( this.flatShading !== undefined ) data.flatShading = this.flatShading; - if ( this.fog === false ) data.fog = false; + if ( this.fog !== undefined ) data.fog = this.fog; if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData; diff --git a/src/nodes/display/ScreenNode.js b/src/nodes/display/ScreenNode.js index eb1a9c084c4233..3e4afb2389801b 100644 --- a/src/nodes/display/ScreenNode.js +++ b/src/nodes/display/ScreenNode.js @@ -26,7 +26,7 @@ class ScreenNode extends Node { /** * Constructs a new screen node. * - * @param {('coordinate'|'viewport'|'size'|'uv'|'dpr')} scope - The node's scope. + * @param {('coordinate'|'viewport'|'size'|'uv')} scope - The node's scope. */ constructor( scope ) { @@ -39,21 +39,11 @@ class ScreenNode extends Node { * - `ScreenNode.VIEWPORT`: The current viewport defined as a four-dimensional vector. * - `ScreenNode.SIZE`: The dimensions of the current bound framebuffer. * - `ScreenNode.UV`: Normalized coordinates. - * - `ScreenNode.DPR`: Device pixel ratio. * - * @type {('coordinate'|'viewport'|'size'|'uv'|'dpr')} + * @type {('coordinate'|'viewport'|'size'|'uv')} */ this.scope = scope; - /** - * This output node. - * - * @private - * @type {?Node} - * @default null - */ - this._output = null; - /** * This flag can be used for type testing. * @@ -68,11 +58,10 @@ class ScreenNode extends Node { /** * This method is overwritten since the node type depends on the selected scope. * - * @return {('float'|'vec2'|'vec4')} The node type. + * @return {('vec2'|'vec4')} The node type. */ generateNodeType() { - if ( this.scope === ScreenNode.DPR ) return 'float'; if ( this.scope === ScreenNode.VIEWPORT ) return 'vec4'; else return 'vec2'; @@ -87,7 +76,7 @@ class ScreenNode extends Node { let updateType = NodeUpdateType.NONE; - if ( this.scope === ScreenNode.SIZE || this.scope === ScreenNode.VIEWPORT || this.scope === ScreenNode.DPR ) { + if ( this.scope === ScreenNode.SIZE || this.scope === ScreenNode.VIEWPORT ) { updateType = NodeUpdateType.RENDER; @@ -123,10 +112,6 @@ class ScreenNode extends Node { } - } else if ( this.scope === ScreenNode.DPR ) { - - this._output.value = renderer.getPixelRatio(); - } else { if ( renderTarget !== null ) { @@ -158,18 +143,12 @@ class ScreenNode extends Node { output = uniform( _viewportVec || ( _viewportVec = new Vector4() ) ).setGroup( renderGroup ); - } else if ( scope === ScreenNode.DPR ) { - - output = uniform( 1 ).setGroup( renderGroup ); - } else { output = vec2( screenCoordinate.div( screenSize ) ); } - this._output = output; - return output; } @@ -204,7 +183,6 @@ ScreenNode.COORDINATE = 'coordinate'; ScreenNode.VIEWPORT = 'viewport'; ScreenNode.SIZE = 'size'; ScreenNode.UV = 'uv'; -ScreenNode.DPR = 'dpr'; export default ScreenNode; @@ -214,9 +192,9 @@ export default ScreenNode; * TSL object that represents the current DPR. * * @tsl - * @type {ScreenNode} + * @type {UniformNode} */ -export const screenDPR = /*@__PURE__*/ nodeImmutable( ScreenNode, ScreenNode.DPR ); +export const screenDPR = /*@__PURE__*/ uniform( 1 ).setGroup( renderGroup ).onRenderUpdate( ( { renderer } ) => renderer.getPixelRatio() ); /** * TSL object that represents normalized screen coordinates, unitless in `[0, 1]`. diff --git a/src/objects/LOD.js b/src/objects/LOD.js index 6219e62c9c793b..aa21d0980944cc 100644 --- a/src/objects/LOD.js +++ b/src/objects/LOD.js @@ -301,7 +301,7 @@ class LOD extends Object3D { const data = super.toJSON( meta ); - if ( this.autoUpdate === false ) data.object.autoUpdate = false; + data.object.autoUpdate = this.autoUpdate; data.object.levels = []; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 57fa6c3e8d308e..a5dd5e36c73871 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -3066,6 +3066,23 @@ class WebGLRenderer { }; + function getReadableState( texture ) { + + const textureProperties = properties.get( texture ); + + if ( textureProperties.__readFormat !== texture.format || textureProperties.__readType !== texture.type ) { + + textureProperties.__readFormat = texture.format; + textureProperties.__readType = texture.type; + textureProperties.__formatReadable = capabilities.textureFormatReadable( texture.format ); + textureProperties.__typeReadable = capabilities.textureTypeReadable( texture.type ); + + } + + return textureProperties; + + } + /** * Reads the pixel data from the given render target into the given buffer. * @@ -3109,14 +3126,16 @@ class WebGLRenderer { if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex ); - if ( ! capabilities.textureFormatReadable( textureFormat ) ) { + const readableState = getReadableState( texture ); + + if ( readableState.__formatReadable === false ) { error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' ); return; } - if ( ! capabilities.textureTypeReadable( textureType ) ) { + if ( readableState.__typeReadable === false ) { error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' ); return; @@ -3191,14 +3210,15 @@ class WebGLRenderer { if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex ); + const readableState = getReadableState( texture ); - if ( ! capabilities.textureFormatReadable( textureFormat ) ) { + if ( readableState.__formatReadable === false ) { throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' ); } - if ( ! capabilities.textureTypeReadable( textureType ) ) { + if ( readableState.__typeReadable === false ) { throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' ); diff --git a/src/renderers/webgl/WebGLCapabilities.js b/src/renderers/webgl/WebGLCapabilities.js index 3b906bbeef3c1e..8bb62a8473e6c3 100644 --- a/src/renderers/webgl/WebGLCapabilities.js +++ b/src/renderers/webgl/WebGLCapabilities.js @@ -41,8 +41,8 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) { const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ); - if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513) - textureType !== FloatType && ! halfFloatSupportedByExt ) { + if ( textureType !== UnsignedByteType && textureType !== FloatType && ! halfFloatSupportedByExt && + utils.convert( textureType ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE ) ) { // Edge and Chrome Mac < 52 (#9513) return false; diff --git a/src/scenes/Scene.js b/src/scenes/Scene.js index 151b76fe4810e7..21bcb96007df7b 100644 --- a/src/scenes/Scene.js +++ b/src/scenes/Scene.js @@ -149,11 +149,11 @@ class Scene extends Object3D { if ( this.fog !== null ) data.object.fog = this.fog.toJSON(); - if ( this.backgroundBlurriness > 0 ) data.object.backgroundBlurriness = this.backgroundBlurriness; - if ( this.backgroundIntensity !== 1 ) data.object.backgroundIntensity = this.backgroundIntensity; + data.object.backgroundBlurriness = this.backgroundBlurriness; + data.object.backgroundIntensity = this.backgroundIntensity; data.object.backgroundRotation = this.backgroundRotation.toArray(); - if ( this.environmentIntensity !== 1 ) data.object.environmentIntensity = this.environmentIntensity; + data.object.environmentIntensity = this.environmentIntensity; data.object.environmentRotation = this.environmentRotation.toArray(); return data; diff --git a/src/textures/DepthTexture.js b/src/textures/DepthTexture.js index 87ccb3e16e6536..12f007341dfd96 100644 --- a/src/textures/DepthTexture.js +++ b/src/textures/DepthTexture.js @@ -93,7 +93,7 @@ class DepthTexture extends Texture { const data = super.toJSON( meta ); - if ( this.compareFunction !== null ) data.compareFunction = this.compareFunction; + data.compareFunction = this.compareFunction; return data; diff --git a/test/unit/src/core/BufferAttribute.tests.js b/test/unit/src/core/BufferAttribute.tests.js index c1a4435b7b10d1..6c27c0ca23ad7b 100644 --- a/test/unit/src/core/BufferAttribute.tests.js +++ b/test/unit/src/core/BufferAttribute.tests.js @@ -11,7 +11,7 @@ import { Float32BufferAttribute } from '../../../../src/core/BufferAttribute.js'; -import { DynamicDrawUsage } from '../../../../src/constants.js'; +import { DynamicDrawUsage, StaticDrawUsage, FloatType } from '../../../../src/constants.js'; import { toHalfFloat, fromHalfFloat } from '../../../../src/extras/DataUtils.js'; export default QUnit.module( 'Core', () => { @@ -194,7 +194,10 @@ export default QUnit.module( 'Core', () => { itemSize: 3, type: 'Float32Array', array: [ 1, 2, 3, 4, 5, 6 ], - normalized: false + normalized: false, + name: '', + usage: StaticDrawUsage, + gpuType: FloatType }, 'Serialized to JSON as expected' ); const attr2 = new BufferAttribute( new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ), 3, true ); @@ -208,6 +211,7 @@ export default QUnit.module( 'Core', () => { normalized: true, name: 'attributeName', usage: DynamicDrawUsage, + gpuType: FloatType }, 'Serialized to JSON as expected with non-default values' ); } ); diff --git a/test/unit/src/core/BufferGeometry.tests.js b/test/unit/src/core/BufferGeometry.tests.js index 565e640e6e8e26..73a092451ffdfd 100644 --- a/test/unit/src/core/BufferGeometry.tests.js +++ b/test/unit/src/core/BufferGeometry.tests.js @@ -13,6 +13,7 @@ import { Sphere } from '../../../../src/math/Sphere.js'; import { x, y, z } from '../../utils/math-constants.js'; import { EventDispatcher } from '../../../../src/core/EventDispatcher.js'; import { toHalfFloat } from '../../../../src/extras/DataUtils.js'; +import { StaticDrawUsage, FloatType } from '../../../../src/constants.js'; const DegToRad = Math.PI / 180; @@ -566,7 +567,9 @@ export default QUnit.module( 'Core', () => { 'type': 'Uint16Array', 'array': [ 1, 3, 5, 7 ], 'normalized': false, - 'name': 'attribute1' + 'name': 'attribute1', + 'usage': StaticDrawUsage, + 'gpuType': FloatType } }, 'index': { @@ -599,7 +602,9 @@ export default QUnit.module( 'Core', () => { 'type': 'Uint16Array', 'array': [ 1, 3, 5, 7 ], 'normalized': false, - 'name': 'attribute1' + 'name': 'attribute1', + 'usage': StaticDrawUsage, + 'gpuType': FloatType } ] }; gold.data.morphTargetsRelative = false; diff --git a/test/unit/src/core/Object3D.tests.js b/test/unit/src/core/Object3D.tests.js index b49f952c805536..1cacee9d82b4f0 100644 --- a/test/unit/src/core/Object3D.tests.js +++ b/test/unit/src/core/Object3D.tests.js @@ -1096,6 +1096,10 @@ export default QUnit.module( 'Core', () => { 'castShadow': true, 'receiveShadow': true, 'visible': false, + 'frustumCulled': true, + 'renderOrder': 0, + 'static': false, + 'matrixAutoUpdate': true, 'userData': { 'foo': 'bar' }, 'layers': 1, 'matrix': [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], @@ -1103,12 +1107,28 @@ export default QUnit.module( 'Core', () => { { 'uuid': '5D4E9AE8-DA61-4912-A575-71A5BE3D72CD', 'type': 'Object3D', + 'name': '', + 'castShadow': false, + 'receiveShadow': false, + 'visible': true, + 'frustumCulled': true, + 'renderOrder': 0, + 'static': false, + 'matrixAutoUpdate': true, 'layers': 1, 'matrix': [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ], 'children': [ { 'uuid': 'B43854B3-E970-4E85-BD41-AAF8D7BFA189', 'type': 'Object3D', + 'name': '', + 'castShadow': false, + 'receiveShadow': false, + 'visible': true, + 'frustumCulled': true, + 'renderOrder': 0, + 'static': false, + 'matrixAutoUpdate': true, 'layers': 1, 'matrix': [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ], 'up': [ 0, 1, 0 ] diff --git a/test/unit/utils/qunit-utils.js b/test/unit/utils/qunit-utils.js index 4095ed7db2553b..03b6f33912edc5 100644 --- a/test/unit/utils/qunit-utils.js +++ b/test/unit/utils/qunit-utils.js @@ -141,7 +141,7 @@ function checkGeometryJsonWriting( geom, json ) { // All parameters from json should be transferred to the geometry. // json is flat. Ignore first level json properties that are not parameters. - const notParameters = [ 'metadata', 'uuid', 'type' ]; + const notParameters = [ 'metadata', 'uuid', 'type', 'name' ]; keys = Object.keys( json ); for ( let i = 0, l = keys.length; i < l; i ++ ) {