@needle-tools/three 0.153.0 → 0.154.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +112 -364
- package/build/three.js +112 -364
- package/build/three.min.js +1 -1
- package/build/three.module.js +113 -346
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +2 -1
- package/examples/jsm/controls/FlyControls.js +25 -9
- package/examples/jsm/controls/OrbitControls.js +7 -1
- package/examples/jsm/csm/CSM.js +1 -1
- package/examples/jsm/effects/AnaglyphEffect.js +1 -1
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/effects/ParallaxBarrierEffect.js +1 -1
- package/examples/jsm/environments/RoomEnvironment.js +6 -2
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +5 -1
- package/examples/jsm/loaders/AMFLoader.js +5 -1
- package/examples/jsm/loaders/ColladaLoader.js +4 -1
- package/examples/jsm/loaders/FBXLoader.js +9 -2
- package/examples/jsm/loaders/LDrawLoader.js +4 -7
- package/examples/jsm/loaders/PLYLoader.js +16 -6
- package/examples/jsm/loaders/VRMLLoader.js +16 -4
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -2
- package/examples/jsm/math/MeshSurfaceSampler.js +76 -35
- package/examples/jsm/nodes/Nodes.js +20 -15
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +21 -8
- package/examples/jsm/nodes/accessors/CameraNode.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +7 -1
- package/examples/jsm/nodes/accessors/InstanceNode.js +2 -4
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -47
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -1
- package/examples/jsm/nodes/accessors/MorphNode.js +70 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +3 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +10 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +46 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -62
- package/examples/jsm/nodes/accessors/TangentNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +68 -6
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/code/CodeNode.js +3 -0
- package/examples/jsm/nodes/code/FunctionNode.js +25 -4
- package/examples/jsm/nodes/core/BypassNode.js +2 -2
- package/examples/jsm/nodes/core/ContextNode.js +2 -0
- package/examples/jsm/nodes/core/IndexNode.js +66 -0
- package/examples/jsm/nodes/core/LightingModel.js +2 -1
- package/examples/jsm/nodes/core/Node.js +12 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +24 -5
- package/examples/jsm/nodes/core/PropertyNode.js +4 -0
- package/examples/jsm/nodes/core/StackNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -3
- package/examples/jsm/nodes/display/BlendModeNode.js +9 -9
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +7 -7
- package/examples/jsm/nodes/display/ColorSpaceNode.js +50 -49
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -8
- package/examples/jsm/nodes/display/ViewportDepthNode.js +69 -0
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +34 -0
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -5
- package/examples/jsm/nodes/display/ViewportTextureNode.js +23 -15
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +5 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -8
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +43 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +2 -4
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/examples/jsm/nodes/functions/PhongLightingModel.js +7 -7
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +129 -18
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/examples/jsm/nodes/functions/material/getRoughness.js +3 -3
- package/examples/jsm/nodes/geometry/RangeNode.js +1 -1
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +91 -62
- package/examples/jsm/nodes/lighting/LightUtils.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +17 -15
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +3 -3
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +41 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +1 -14
- package/examples/jsm/nodes/materials/NodeMaterial.js +79 -28
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +3 -3
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +14 -14
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +4 -4
- package/examples/jsm/nodes/math/MathNode.js +6 -0
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +24 -4
- package/examples/jsm/nodes/utils/LoopNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +1 -1
- package/examples/jsm/objects/GroundProjectedSkybox.js +1 -1
- package/examples/jsm/objects/Reflector.js +1 -1
- package/examples/jsm/objects/Refractor.js +1 -1
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/Water.js +1 -1
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/offscreen/scene.js +1 -0
- package/examples/jsm/postprocessing/EffectComposer.js +2 -0
- package/examples/jsm/postprocessing/OutlinePass.js +1 -3
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -12
- package/examples/jsm/postprocessing/SavePass.js +3 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +14 -2
- package/examples/jsm/postprocessing/TexturePass.js +2 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +9 -10
- package/examples/jsm/renderers/common/Backend.js +2 -0
- package/examples/jsm/renderers/common/Background.js +7 -6
- package/examples/jsm/renderers/common/Pipelines.js +26 -14
- package/examples/jsm/renderers/common/RenderObject.js +18 -0
- package/examples/jsm/renderers/common/RenderObjects.js +29 -29
- package/examples/jsm/renderers/common/Renderer.js +48 -6
- package/examples/jsm/renderers/common/nodes/Nodes.js +1 -1
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +340 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +23 -19
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +123 -41
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +29 -9
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +8 -13
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +85 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +5 -1
- package/examples/jsm/shaders/BlendShader.js +1 -2
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/CopyShader.js +2 -2
- package/examples/jsm/shaders/ToonShader.js +4 -4
- package/examples/jsm/shaders/WaterRefractionShader.js +1 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +34 -13
- package/package.json +2 -1
- package/src/Three.Legacy.js +0 -228
- package/src/animation/PropertyBinding.js +1 -1
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -24
- package/src/core/BufferGeometry.js +0 -7
- package/src/loaders/Loader.js +2 -0
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/materials/Material.js +3 -0
- package/src/objects/Skeleton.js +0 -2
- package/src/renderers/WebGLRenderer.js +9 -21
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +10 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/points.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +4 -2
- package/src/renderers/webgl/WebGLObjects.js +23 -3
- package/src/renderers/webgl/WebGLProgram.js +24 -5
- package/src/renderers/webgl/WebGLPrograms.js +3 -0
- package/src/renderers/webxr/WebXRManager.js +11 -29
- package/src/scenes/Scene.js +0 -14
- package/examples/jsm/nodes/core/InstanceIndexNode.js +0 -45
- /package/src/renderers/shaders/ShaderChunk/{encodings_fragment.glsl.js → colorspace_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{encodings_pars_fragment.glsl.js → colorspace_pars_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{output_fragment.glsl.js → opaque_fragment.glsl.js} +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NoColorSpace } from 'three';
|
|
2
|
+
|
|
1
3
|
import UniformsGroup from '../../common/UniformsGroup.js';
|
|
2
4
|
import {
|
|
3
5
|
FloatNodeUniform, Vector2NodeUniform, Vector3NodeUniform, Vector4NodeUniform,
|
|
@@ -96,11 +98,11 @@ fn threejs_repeatWrapping( uv : vec2<f32>, dimension : vec2<u32> ) -> vec2<u32>
|
|
|
96
98
|
` )
|
|
97
99
|
};
|
|
98
100
|
|
|
99
|
-
class
|
|
101
|
+
class WGSLNodeBuilder extends NodeBuilder {
|
|
100
102
|
|
|
101
|
-
constructor( object, renderer ) {
|
|
103
|
+
constructor( object, renderer, scene = null ) {
|
|
102
104
|
|
|
103
|
-
super( object, renderer, new WGSLNodeParser() );
|
|
105
|
+
super( object, renderer, new WGSLNodeParser(), scene );
|
|
104
106
|
|
|
105
107
|
this.uniformsGroup = {};
|
|
106
108
|
|
|
@@ -131,6 +133,12 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
131
133
|
|
|
132
134
|
}
|
|
133
135
|
|
|
136
|
+
needsColorSpaceToLinear( texture ) {
|
|
137
|
+
|
|
138
|
+
return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
134
142
|
getSampler( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
|
|
135
143
|
|
|
136
144
|
if ( shaderStage === 'fragment' ) {
|
|
@@ -252,9 +260,9 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
252
260
|
|
|
253
261
|
}
|
|
254
262
|
|
|
255
|
-
getUniformFromNode( node, type, shaderStage ) {
|
|
263
|
+
getUniformFromNode( node, type, shaderStage, name = null ) {
|
|
256
264
|
|
|
257
|
-
const uniformNode = super.getUniformFromNode( node, type, shaderStage );
|
|
265
|
+
const uniformNode = super.getUniformFromNode( node, type, shaderStage, name );
|
|
258
266
|
const nodeData = this.getDataFromNode( node, shaderStage );
|
|
259
267
|
|
|
260
268
|
if ( nodeData.uniformGPU === undefined ) {
|
|
@@ -392,6 +400,18 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
392
400
|
|
|
393
401
|
}
|
|
394
402
|
|
|
403
|
+
getVertexIndex() {
|
|
404
|
+
|
|
405
|
+
if ( this.shaderStage === 'vertex' ) {
|
|
406
|
+
|
|
407
|
+
return this.getBuiltin( 'vertex_index', 'vertexIndex', 'u32', 'attribute' );
|
|
408
|
+
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return 'vertexIndex';
|
|
412
|
+
|
|
413
|
+
}
|
|
414
|
+
|
|
395
415
|
getInstanceIndex() {
|
|
396
416
|
|
|
397
417
|
if ( this.shaderStage === 'vertex' ) {
|
|
@@ -510,7 +530,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
510
530
|
|
|
511
531
|
snippets.push( `${ attributesSnippet } ${ varying.name } : ${ this.getType( varying.type ) }` );
|
|
512
532
|
|
|
513
|
-
} else if ( vars.includes( varying ) === false ) {
|
|
533
|
+
} else if ( shaderStage === 'vertex' && vars.includes( varying ) === false ) {
|
|
514
534
|
|
|
515
535
|
vars.push( varying );
|
|
516
536
|
|
|
@@ -548,7 +568,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
548
568
|
|
|
549
569
|
if ( shaderStage === 'fragment' ) {
|
|
550
570
|
|
|
551
|
-
bindingSnippets.push( `@
|
|
571
|
+
bindingSnippets.push( `@binding( ${index ++} ) @group( 0 ) var ${uniform.name}_sampler : sampler;` );
|
|
552
572
|
|
|
553
573
|
}
|
|
554
574
|
|
|
@@ -574,7 +594,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
574
594
|
|
|
575
595
|
}
|
|
576
596
|
|
|
577
|
-
bindingSnippets.push( `@
|
|
597
|
+
bindingSnippets.push( `@binding( ${index ++} ) @group( 0 ) var ${uniform.name} : ${textureType};` );
|
|
578
598
|
|
|
579
599
|
} else if ( uniform.type === 'buffer' || uniform.type === 'storageBuffer' ) {
|
|
580
600
|
|
|
@@ -855,4 +875,4 @@ var<${access}> ${name} : ${structName};`;
|
|
|
855
875
|
|
|
856
876
|
}
|
|
857
877
|
|
|
858
|
-
export default
|
|
878
|
+
export default WGSLNodeBuilder;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Float16BufferAttribute } from 'three';
|
|
2
|
+
import { GPUInputStepMode } from './WebGPUConstants.js';
|
|
2
3
|
|
|
3
4
|
const typedArraysToVertexFormatPrefix = new Map( [
|
|
4
5
|
[ Int8Array, [ 'sint8', 'snorm8' ]],
|
|
@@ -106,6 +107,7 @@ class WebGPUAttributeUtils {
|
|
|
106
107
|
|
|
107
108
|
let arrayStride = geometryAttribute.itemSize * bytesPerElement;
|
|
108
109
|
let offset = 0;
|
|
110
|
+
let stepMode = geometryAttribute.isInstancedBufferAttribute ? GPUInputStepMode.Instance : GPUInputStepMode.Vertex;
|
|
109
111
|
|
|
110
112
|
if ( geometryAttribute.isInterleavedBufferAttribute === true ) {
|
|
111
113
|
|
|
@@ -113,12 +115,14 @@ class WebGPUAttributeUtils {
|
|
|
113
115
|
|
|
114
116
|
arrayStride = geometryAttribute.data.stride * bytesPerElement;
|
|
115
117
|
offset = geometryAttribute.offset * bytesPerElement;
|
|
118
|
+
if ( geometryAttribute.data.isInstancedInterleavedBuffer ) stepMode = GPUInputStepMode.Instance;
|
|
116
119
|
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
shaderAttributes.push( {
|
|
120
123
|
geometryAttribute,
|
|
121
124
|
arrayStride,
|
|
125
|
+
stepMode,
|
|
122
126
|
offset,
|
|
123
127
|
format,
|
|
124
128
|
slot
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlendColorFactor, OneMinusBlendColorFactor, } from '../../common/Constants.js';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
GPUFrontFace, GPUCullMode, GPUColorWriteFlags, GPUCompareFunction, GPUBlendFactor, GPUBlendOperation, GPUIndexFormat, GPUStencilOperation
|
|
5
5
|
} from './WebGPUConstants.js';
|
|
6
6
|
|
|
7
7
|
import {
|
|
@@ -44,26 +44,24 @@ class WebGPUPipelineUtils {
|
|
|
44
44
|
|
|
45
45
|
for ( const attribute of shaderAttributes ) {
|
|
46
46
|
|
|
47
|
-
const geometryAttribute = attribute.geometryAttribute;
|
|
48
|
-
const stepMode = ( geometryAttribute !== undefined && geometryAttribute.isInstancedBufferAttribute ) ? GPUInputStepMode.Instance : GPUInputStepMode.Vertex;
|
|
49
|
-
|
|
50
47
|
vertexBuffers.push( {
|
|
51
48
|
arrayStride: attribute.arrayStride,
|
|
52
49
|
attributes: [ { shaderLocation: attribute.slot, offset: attribute.offset, format: attribute.format } ],
|
|
53
|
-
stepMode: stepMode
|
|
50
|
+
stepMode: attribute.stepMode
|
|
54
51
|
} );
|
|
55
52
|
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
// blending
|
|
59
56
|
|
|
60
|
-
let
|
|
61
|
-
let colorBlend = {};
|
|
57
|
+
let blending;
|
|
62
58
|
|
|
63
59
|
if ( material.transparent === true && material.blending !== NoBlending ) {
|
|
64
60
|
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
blending = {
|
|
62
|
+
alpha: this._getAlphaBlend( material ),
|
|
63
|
+
color: this._getColorBlend( material )
|
|
64
|
+
};
|
|
67
65
|
|
|
68
66
|
}
|
|
69
67
|
|
|
@@ -98,10 +96,7 @@ class WebGPUPipelineUtils {
|
|
|
98
96
|
vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
|
|
99
97
|
fragment: Object.assign( {}, fragmentModule, { targets: [ {
|
|
100
98
|
format: colorFormat,
|
|
101
|
-
blend:
|
|
102
|
-
alpha: alphaBlend,
|
|
103
|
-
color: colorBlend
|
|
104
|
-
},
|
|
99
|
+
blend: blending,
|
|
105
100
|
writeMask: colorWriteMask
|
|
106
101
|
} ] } ),
|
|
107
102
|
primitive: primitiveState,
|
|
@@ -86,7 +86,7 @@ class WebGPUTextureUtils {
|
|
|
86
86
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
createTexture( texture ) {
|
|
89
|
+
createTexture( texture, options = {} ) {
|
|
90
90
|
|
|
91
91
|
const backend = this.backend;
|
|
92
92
|
const textureData = backend.get( texture );
|
|
@@ -104,9 +104,9 @@ class WebGPUTextureUtils {
|
|
|
104
104
|
const mipLevelCount = this._getMipLevelCount( texture, width, height, needsMipmaps );
|
|
105
105
|
const format = texture.internalFormat || this._getFormat( texture );
|
|
106
106
|
//const sampleCount = texture.isRenderTargetTexture || texture.isDepthTexture ? backend.utils.getSampleCount( renderContext ) : 1;
|
|
107
|
-
const sampleCount = 1;
|
|
107
|
+
const sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
|
|
108
108
|
|
|
109
|
-
let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST;
|
|
109
|
+
let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
|
|
110
110
|
|
|
111
111
|
if ( texture.isCompressedTexture !== true ) {
|
|
112
112
|
|
|
@@ -245,6 +245,52 @@ class WebGPUTextureUtils {
|
|
|
245
245
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
async copyTextureToBuffer( texture, x, y, width, height ) {
|
|
249
|
+
|
|
250
|
+
const device = this.backend.device;
|
|
251
|
+
|
|
252
|
+
const textureData = this.backend.get( texture );
|
|
253
|
+
const textureGPU = textureData.texture;
|
|
254
|
+
const format = textureData.textureDescriptorGPU.format;
|
|
255
|
+
const bytesPerTexel = this._getBytesPerTexel( format );
|
|
256
|
+
|
|
257
|
+
const readBuffer = device.createBuffer(
|
|
258
|
+
{
|
|
259
|
+
size: width * height * bytesPerTexel,
|
|
260
|
+
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
const encoder = device.createCommandEncoder();
|
|
265
|
+
|
|
266
|
+
encoder.copyTextureToBuffer(
|
|
267
|
+
{
|
|
268
|
+
texture: textureGPU,
|
|
269
|
+
origin: { x, y },
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
buffer: readBuffer,
|
|
273
|
+
bytesPerRow: width * bytesPerTexel
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
width: width,
|
|
277
|
+
height: height
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
const typedArrayType = this._getTypedArrayType( format );
|
|
283
|
+
|
|
284
|
+
device.queue.submit( [ encoder.finish() ] );
|
|
285
|
+
|
|
286
|
+
await readBuffer.mapAsync( GPUMapMode.READ );
|
|
287
|
+
|
|
288
|
+
const buffer = readBuffer.getMappedRange();
|
|
289
|
+
|
|
290
|
+
return new typedArrayType( buffer );
|
|
291
|
+
|
|
292
|
+
}
|
|
293
|
+
|
|
248
294
|
_isEnvironmentTexture( texture ) {
|
|
249
295
|
|
|
250
296
|
const mapping = texture.mapping;
|
|
@@ -579,6 +625,42 @@ class WebGPUTextureUtils {
|
|
|
579
625
|
|
|
580
626
|
}
|
|
581
627
|
|
|
628
|
+
_getTypedArrayType( format ) {
|
|
629
|
+
|
|
630
|
+
if ( format === GPUTextureFormat.R8Uint ) return Uint8Array;
|
|
631
|
+
if ( format === GPUTextureFormat.R8Sint ) return Int8Array;
|
|
632
|
+
if ( format === GPUTextureFormat.R8Unorm ) return Uint8Array;
|
|
633
|
+
if ( format === GPUTextureFormat.R8Snorm ) return Int8Array;
|
|
634
|
+
if ( format === GPUTextureFormat.RG8Uint ) return Uint8Array;
|
|
635
|
+
if ( format === GPUTextureFormat.RG8Sint ) return Int8Array;
|
|
636
|
+
if ( format === GPUTextureFormat.RG8Unorm ) return Uint8Array;
|
|
637
|
+
if ( format === GPUTextureFormat.RG8Snorm ) return Int8Array;
|
|
638
|
+
if ( format === GPUTextureFormat.RGBA8Uint ) return Uint8Array;
|
|
639
|
+
if ( format === GPUTextureFormat.RGBA8Sint ) return Int8Array;
|
|
640
|
+
if ( format === GPUTextureFormat.RGBA8Unorm ) return Uint8Array;
|
|
641
|
+
if ( format === GPUTextureFormat.RGBA8Snorm ) return Int8Array;
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
if ( format === GPUTextureFormat.R16Uint ) return Uint16Array;
|
|
645
|
+
if ( format === GPUTextureFormat.R16Sint ) return Int16Array;
|
|
646
|
+
if ( format === GPUTextureFormat.RG16Uint ) return Uint16Array;
|
|
647
|
+
if ( format === GPUTextureFormat.RG16Sint ) return Int16Array;
|
|
648
|
+
if ( format === GPUTextureFormat.RGBA16Uint ) return Uint16Array;
|
|
649
|
+
if ( format === GPUTextureFormat.RGBA16Sint ) return Int16Array;
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
if ( format === GPUTextureFormat.R32Uint ) return Uint32Array;
|
|
653
|
+
if ( format === GPUTextureFormat.R32Sint ) return Int32Array;
|
|
654
|
+
if ( format === GPUTextureFormat.R32Float ) return Float32Array;
|
|
655
|
+
if ( format === GPUTextureFormat.RG32Uint ) return Uint32Array;
|
|
656
|
+
if ( format === GPUTextureFormat.RG32Sint ) return Int32Array;
|
|
657
|
+
if ( format === GPUTextureFormat.RG32Float ) return Float32Array;
|
|
658
|
+
if ( format === GPUTextureFormat.RGBA32Uint ) return Uint32Array;
|
|
659
|
+
if ( format === GPUTextureFormat.RGBA32Sint ) return Int32Array;
|
|
660
|
+
if ( format === GPUTextureFormat.RGBA32Float ) return Float32Array;
|
|
661
|
+
|
|
662
|
+
}
|
|
663
|
+
|
|
582
664
|
_getDimension( texture ) {
|
|
583
665
|
|
|
584
666
|
let dimension;
|
|
@@ -16,10 +16,14 @@ class WebGPUUtils {
|
|
|
16
16
|
|
|
17
17
|
format = this.getTextureFormatGPU( renderContext.depthTexture );
|
|
18
18
|
|
|
19
|
-
} else {
|
|
19
|
+
} else if ( renderContext.depth && renderContext.stencil ) {
|
|
20
20
|
|
|
21
21
|
format = GPUTextureFormat.Depth24PlusStencil8;
|
|
22
22
|
|
|
23
|
+
} else if ( renderContext.depth ) {
|
|
24
|
+
|
|
25
|
+
format = GPUTextureFormat.Depth24Plus;
|
|
26
|
+
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
return format;
|
|
@@ -38,8 +38,7 @@ const BlendShader = {
|
|
|
38
38
|
|
|
39
39
|
vec4 texel1 = texture2D( tDiffuse1, vUv );
|
|
40
40
|
vec4 texel2 = texture2D( tDiffuse2, vUv );
|
|
41
|
-
gl_FragColor = mix( texel1, texel2, mixRatio );
|
|
42
|
-
gl_FragColor.a *= opacity;
|
|
41
|
+
gl_FragColor = opacity * mix( texel1, texel2, mixRatio );
|
|
43
42
|
|
|
44
43
|
}`
|
|
45
44
|
|
|
@@ -80,7 +80,7 @@ const ToonShader1 = {
|
|
|
80
80
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
#include <
|
|
83
|
+
#include <colorspace_fragment>
|
|
84
84
|
|
|
85
85
|
}`
|
|
86
86
|
|
|
@@ -148,7 +148,7 @@ const ToonShader2 = {
|
|
|
148
148
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
#include <
|
|
151
|
+
#include <colorspace_fragment>
|
|
152
152
|
|
|
153
153
|
}`
|
|
154
154
|
|
|
@@ -244,7 +244,7 @@ const ToonShaderHatching = {
|
|
|
244
244
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
#include <
|
|
247
|
+
#include <colorspace_fragment>
|
|
248
248
|
|
|
249
249
|
}`
|
|
250
250
|
|
|
@@ -317,7 +317,7 @@ const ToonShaderDotted = {
|
|
|
317
317
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
#include <
|
|
320
|
+
#include <colorspace_fragment>
|
|
321
321
|
|
|
322
322
|
}`
|
|
323
323
|
|
|
@@ -13,8 +13,8 @@ const POINTER_LENGTH = 0.035;
|
|
|
13
13
|
const POINTER_SEGMENTS = 16;
|
|
14
14
|
const POINTER_RINGS = 12;
|
|
15
15
|
const POINTER_HEMISPHERE_ANGLE = 110;
|
|
16
|
-
const YAXIS = new THREE.Vector3( 0, 1, 0 );
|
|
17
|
-
const ZAXIS = new THREE.Vector3( 0, 0, 1 );
|
|
16
|
+
const YAXIS = /* @__PURE__ */ new THREE.Vector3( 0, 1, 0 );
|
|
17
|
+
const ZAXIS = /* @__PURE__ */ new THREE.Vector3( 0, 0, 1 );
|
|
18
18
|
|
|
19
19
|
const CURSOR_RADIUS = 0.02;
|
|
20
20
|
const CURSOR_MAX_DISTANCE = 1.5;
|
|
@@ -27,9 +27,10 @@ class OculusHandPointerModel extends THREE.Object3D {
|
|
|
27
27
|
|
|
28
28
|
this.hand = hand;
|
|
29
29
|
this.controller = controller;
|
|
30
|
+
|
|
31
|
+
// Unused
|
|
30
32
|
this.motionController = null;
|
|
31
33
|
this.envMap = null;
|
|
32
|
-
|
|
33
34
|
this.mesh = null;
|
|
34
35
|
|
|
35
36
|
this.pointerGeometry = null;
|
|
@@ -43,24 +44,36 @@ class OculusHandPointerModel extends THREE.Object3D {
|
|
|
43
44
|
|
|
44
45
|
this.raycaster = null;
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
this._onConnected = this._onConnected.bind( this );
|
|
48
|
+
this._onDisconnected = this._onDisconnected.bind( this );
|
|
49
|
+
this.hand.addEventListener( 'connected', this._onConnected );
|
|
50
|
+
this.hand.addEventListener( 'disconnected', this._onDisconnected );
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
}
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
_onConnected( event ) {
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
const xrInputSource = event.data;
|
|
57
|
+
if ( xrInputSource.hand ) {
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
this.visible = true;
|
|
60
|
+
this.xrInputSource = xrInputSource;
|
|
56
61
|
|
|
57
|
-
|
|
62
|
+
this.createPointer();
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
}
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_onDisconnected() {
|
|
62
69
|
|
|
63
|
-
|
|
70
|
+
this.visible = false;
|
|
71
|
+
this.xrInputSource = null;
|
|
72
|
+
|
|
73
|
+
if (this.pointerGeometry) this.pointerGeometry.dispose();
|
|
74
|
+
if (this.pointerMesh && this.pointerMesh.material) this.pointerMesh.material.dispose();
|
|
75
|
+
|
|
76
|
+
this.clear();
|
|
64
77
|
|
|
65
78
|
}
|
|
66
79
|
|
|
@@ -389,6 +402,14 @@ class OculusHandPointerModel extends THREE.Object3D {
|
|
|
389
402
|
|
|
390
403
|
}
|
|
391
404
|
|
|
405
|
+
dispose() {
|
|
406
|
+
|
|
407
|
+
this._onDisconnected();
|
|
408
|
+
this.hand.removeEventListener( 'connected', this._onConnected );
|
|
409
|
+
this.hand.removeEventListener( 'disconnected', this._onDisconnected );
|
|
410
|
+
|
|
411
|
+
}
|
|
412
|
+
|
|
392
413
|
}
|
|
393
414
|
|
|
394
415
|
export { OculusHandPointerModel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/three",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.154.1",
|
|
4
4
|
"description": "JavaScript 3D library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/three.js",
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
},
|
|
85
85
|
"homepage": "https://threejs.org/",
|
|
86
86
|
"devDependencies": {
|
|
87
|
+
"@puppeteer/browsers": "^1.4.1",
|
|
87
88
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
88
89
|
"@rollup/plugin-terser": "^0.4.0",
|
|
89
90
|
"chalk": "^5.2.0",
|