@iwsdk/xr-input 1.0.1-rc.0 → 1.1.0-rc.0

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/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.0.1-rc.0";
1
+ export declare const VERSION = "1.1.0-rc.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"simple-batched-mesh.d.ts","sourceRoot":"","sources":["../../../src/visual/utils/simple-batched-mesh.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EAGL,cAAc,EAGd,QAAQ,EACR,OAAO,EACP,IAAI,EAGL,MAAM,OAAO,CAAC;AAyBf,qBAAa,iBAAkB,SAAQ,IAAI;IAGzC,QAAQ,CAAC,mBAAmB,QAAQ;IAEpC,OAAO,CAAC,WAAW,CAA+C;IAClE,OAAO,CAAC,eAAe,CAKf;IACR,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAKP;IAER,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,cAAc,CAAK;IAG3B,OAAO,CAAC,gBAAgB,CAA4B;gBAGlD,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,YAAqB,EAC1C,QAAQ,EAAE,QAAQ;IAcpB,IAAI,gBAAgB,WAEnB;IAED,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,cAAc;IA2FtB,OAAO,CAAC,mBAAmB;IA6C3B,OAAO,CAAC,iBAAiB;IA0CzB,WAAW,CACT,QAAQ,EAAE,cAAc,EACxB,WAAW,SAAK,EAChB,UAAU,SAAK,GAC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AC,mBAAmB;IA6C3B,OAAO,CAAC,iBAAiB;IA0CzB,WAAW,CACT,QAAQ,EAAE,cAAc,EACxB,WAAW,SAAK,EAChB,UAAU,SAAK,GACd,MAAM;IAqGT,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM;IA0F3D,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAetD,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI;IAWhE,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAgBtD,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAWzC,OAAO;CAIR"}
@@ -1,4 +1,4 @@
1
- import { Matrix4, Mesh, BufferGeometry, DataTexture, RGBAFormat, FloatType, BufferAttribute, Sphere, Box3 } from 'three';
1
+ import { Matrix4, Mesh, BufferGeometry, DataTexture, RGBAFormat, FloatType, BufferAttribute, Sphere, Box3, REVISION } from 'three';
2
2
 
3
3
  /**
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -20,6 +20,8 @@ import { Matrix4, Mesh, BufferGeometry, DataTexture, RGBAFormat, FloatType, Buff
20
20
  */
21
21
  const ID_ATTR_NAME = 'batchId';
22
22
  const _identityMatrix = new Matrix4();
23
+ // Since r183, three's vertex color varying is always a vec4.
24
+ const VEC4_VERTEX_COLORS = parseInt(REVISION) >= 183;
23
25
  // Helper to copy attribute data
24
26
  function copyAttributeData(src, target, targetOffset = 0) {
25
27
  const itemSize = target.itemSize;
@@ -99,12 +101,12 @@ class SimpleBatchedMesh extends Mesh {
99
101
  #endif
100
102
  #ifdef USE_BATCHING_COLOR
101
103
  uniform sampler2D batchingColorTexture;
102
- vec3 getBatchingColor( const in float i ) {
104
+ vec4 getBatchingColor( const in float i ) {
103
105
  int size = textureSize( batchingColorTexture, 0 ).x;
104
106
  int j = int( i );
105
107
  int x = j % size;
106
108
  int y = j / size;
107
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
109
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
108
110
  }
109
111
  #endif
110
112
  `;
@@ -117,9 +119,28 @@ class SimpleBatchedMesh extends Mesh {
117
119
  #endif
118
120
  `;
119
121
  shader.vertexShader = shader.vertexShader.replace('#include <batching_vertex>', batchingVertex);
120
- // Replace color_vertex to use batchId for batching color (r165 style)
121
- // The r181 version uses getIndirectIndex(gl_DrawID) which we don't support
122
- const colorVertex = `
122
+ // Replace color_vertex to use batchId for batching color (r165 style);
123
+ // three's own chunk uses getIndirectIndex(gl_DrawID), which we don't
124
+ // support. vColor is a vec4 since r183 and a vec3 (vec4 with
125
+ // USE_COLOR_ALPHA) before that.
126
+ const colorVertex = VEC4_VERTEX_COLORS
127
+ ? `
128
+ #if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
129
+ vColor = vec4( 1.0 );
130
+ #endif
131
+ #ifdef USE_COLOR_ALPHA
132
+ vColor *= color;
133
+ #elif defined( USE_COLOR )
134
+ vColor.rgb *= color;
135
+ #endif
136
+ #ifdef USE_INSTANCING_COLOR
137
+ vColor.rgb *= instanceColor.rgb;
138
+ #endif
139
+ #ifdef USE_BATCHING_COLOR
140
+ vColor *= getBatchingColor( batchId );
141
+ #endif
142
+ `
143
+ : `
123
144
  #if defined( USE_COLOR_ALPHA )
124
145
  vColor = vec4( 1.0 );
125
146
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
@@ -132,8 +153,7 @@ class SimpleBatchedMesh extends Mesh {
132
153
  vColor.xyz *= instanceColor.xyz;
133
154
  #endif
134
155
  #ifdef USE_BATCHING_COLOR
135
- vec3 batchingColor = getBatchingColor( batchId );
136
- vColor.xyz *= batchingColor.xyz;
156
+ vColor.xyz *= getBatchingColor( batchId ).xyz;
137
157
  #endif
138
158
  `;
139
159
  shader.vertexShader = shader.vertexShader.replace('#include <color_vertex>', colorVertex);
@@ -1 +1 @@
1
- {"version":3,"file":"simple-batched-mesh.js","sources":["../../../src/visual/utils/simple-batched-mesh.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * SimpleBatchedMesh - A multiview-compatible batched mesh implementation\n *\n * This is based on the THREE.js r165 BatchedMesh approach which uses a vertex\n * attribute for batch IDs instead of gl_DrawID. This works correctly with\n * multiview rendering on Quest, where the gl_DrawID-based approach fails.\n *\n * Key differences from modern THREE.js BatchedMesh:\n * - Uses `attribute float batchId` instead of `gl_DrawID`\n * - Simpler API: each geometry is its own instance\n * - No dependency on WEBGL_multi_draw extension\n */\n\nimport {\n Box3,\n BufferAttribute,\n BufferGeometry,\n DataTexture,\n FloatType,\n Material,\n Matrix4,\n Mesh,\n RGBAFormat,\n Sphere,\n} from 'three';\n\nconst ID_ATTR_NAME = 'batchId';\nconst _identityMatrix = new Matrix4();\n\n// Helper to copy attribute data\nfunction copyAttributeData(\n src: BufferAttribute,\n target: BufferAttribute,\n targetOffset = 0,\n) {\n const itemSize = target.itemSize;\n if (src.array.constructor !== target.array.constructor) {\n const vertexCount = src.count;\n for (let i = 0; i < vertexCount; i++) {\n for (let c = 0; c < itemSize; c++) {\n target.setComponent(i + targetOffset, c, src.getComponent(i, c));\n }\n }\n } else {\n target.array.set(src.array, targetOffset * itemSize);\n }\n target.needsUpdate = true;\n}\n\nexport class SimpleBatchedMesh extends Mesh {\n // Do NOT set isBatchedMesh = true - that triggers THREE.js's multi-draw path\n // which we don't support. Instead we handle batching entirely through material patching.\n readonly isSimpleBatchedMesh = true;\n\n private _drawRanges: Array<{ start: number; count: number }> = [];\n private _reservedRanges: Array<{\n vertexStart: number;\n vertexCount: number;\n indexStart: number;\n indexCount: number;\n }> = [];\n private _visibility: boolean[] = [];\n private _active: boolean[] = [];\n private _bounds: Array<{\n boxInitialized: boolean;\n box: Box3;\n sphereInitialized: boolean;\n sphere: Sphere;\n }> = [];\n\n private _maxGeometryCount: number;\n private _maxVertexCount: number;\n private _maxIndexCount: number;\n\n private _geometryInitialized = false;\n private _geometryCount = 0;\n\n // Matrices texture for batch transforms\n private _matricesTexture: DataTexture | null = null;\n\n constructor(\n maxGeometryCount: number,\n maxVertexCount: number,\n maxIndexCount: number = maxVertexCount * 2,\n material: Material,\n ) {\n super(new BufferGeometry(), material);\n\n this._maxGeometryCount = maxGeometryCount;\n this._maxVertexCount = maxVertexCount;\n this._maxIndexCount = maxIndexCount;\n\n this._initMatricesTexture();\n\n // Patch the material to use batchId attribute\n this._patchMaterial(material);\n }\n\n get maxGeometryCount() {\n return this._maxGeometryCount;\n }\n\n private _initMatricesTexture() {\n // Layout: 1 matrix = 4 pixels (RGBA each column)\n let size = Math.sqrt(this._maxGeometryCount * 4);\n size = Math.ceil(size / 4) * 4;\n size = Math.max(size, 4);\n\n const matricesArray = new Float32Array(size * size * 4);\n const matricesTexture = new DataTexture(\n matricesArray,\n size,\n size,\n RGBAFormat,\n FloatType,\n );\n\n this._matricesTexture = matricesTexture;\n }\n\n private _patchMaterial(material: Material) {\n // Add the batchingTexture uniform and onBeforeCompile hook\n const self = this;\n\n material.onBeforeCompile = (shader) => {\n // Add uniforms\n shader.uniforms.batchingTexture = { value: self._matricesTexture };\n\n // Inject USE_BATCHING define at the start of vertex shader\n // (THREE.js won't add it since we don't set isBatchedMesh = true)\n shader.vertexShader = '#define USE_BATCHING\\n' + shader.vertexShader;\n\n // Add batching pars to vertex shader (r165 style with attribute)\n // Includes both matrix lookup and color lookup functions\n const batchingParsVertex = `\n #ifdef USE_BATCHING\n attribute float batchId;\n uniform highp sampler2D batchingTexture;\n mat4 getBatchingMatrix( const in float i ) {\n int size = textureSize( batchingTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n #endif\n #ifdef USE_BATCHING_COLOR\n uniform sampler2D batchingColorTexture;\n vec3 getBatchingColor( const in float i ) {\n int size = textureSize( batchingColorTexture, 0 ).x;\n int j = int( i );\n int x = j % size;\n int y = j / size;\n return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n }\n #endif\n `;\n\n // Replace THREE.js batching_pars_vertex\n shader.vertexShader = shader.vertexShader.replace(\n '#include <batching_pars_vertex>',\n batchingParsVertex,\n );\n\n // Replace batching_vertex to use batchId attribute\n const batchingVertex = `\n #ifdef USE_BATCHING\n mat4 batchingMatrix = getBatchingMatrix( batchId );\n #endif\n `;\n\n shader.vertexShader = shader.vertexShader.replace(\n '#include <batching_vertex>',\n batchingVertex,\n );\n\n // Replace color_vertex to use batchId for batching color (r165 style)\n // The r181 version uses getIndirectIndex(gl_DrawID) which we don't support\n const colorVertex = `\n #if defined( USE_COLOR_ALPHA )\n vColor = vec4( 1.0 );\n #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec3( 1.0 );\n #endif\n #ifdef USE_COLOR\n vColor *= color;\n #endif\n #ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.xyz;\n #endif\n #ifdef USE_BATCHING_COLOR\n vec3 batchingColor = getBatchingColor( batchId );\n vColor.xyz *= batchingColor.xyz;\n #endif\n `;\n\n shader.vertexShader = shader.vertexShader.replace(\n '#include <color_vertex>',\n colorVertex,\n );\n };\n\n // Force material to use batching\n (material as any).batching = true;\n material.needsUpdate = true;\n }\n\n private _initializeGeometry(reference: BufferGeometry) {\n const geometry = this.geometry as BufferGeometry;\n const maxVertexCount = this._maxVertexCount;\n const maxGeometryCount = this._maxGeometryCount;\n const maxIndexCount = this._maxIndexCount;\n\n if (this._geometryInitialized === false) {\n for (const attributeName in reference.attributes) {\n const srcAttribute = reference.getAttribute(\n attributeName,\n ) as BufferAttribute;\n const { array, itemSize, normalized } = srcAttribute;\n\n const dstArray = new (array.constructor as any)(\n maxVertexCount * itemSize,\n );\n const dstAttribute = new BufferAttribute(\n dstArray,\n itemSize,\n normalized,\n );\n\n geometry.setAttribute(attributeName, dstAttribute);\n }\n\n if (reference.getIndex() !== null) {\n const indexArray =\n maxVertexCount > 65536\n ? new Uint32Array(maxIndexCount)\n : new Uint16Array(maxIndexCount);\n\n geometry.setIndex(new BufferAttribute(indexArray, 1));\n }\n\n // Add batchId attribute (the key difference from r181)\n const idArray =\n maxGeometryCount > 65536\n ? new Uint32Array(maxVertexCount)\n : new Uint16Array(maxVertexCount);\n geometry.setAttribute(ID_ATTR_NAME, new BufferAttribute(idArray, 1));\n\n this._geometryInitialized = true;\n }\n }\n\n private _validateGeometry(geometry: BufferGeometry) {\n if (geometry.getAttribute(ID_ATTR_NAME)) {\n throw new Error(\n `SimpleBatchedMesh: Geometry cannot use attribute \"${ID_ATTR_NAME}\"`,\n );\n }\n\n const batchGeometry = this.geometry as BufferGeometry;\n if (Boolean(geometry.getIndex()) !== Boolean(batchGeometry.getIndex())) {\n throw new Error(\n 'SimpleBatchedMesh: All geometries must consistently have \"index\".',\n );\n }\n\n for (const attributeName in batchGeometry.attributes) {\n if (attributeName === ID_ATTR_NAME) {\n continue;\n }\n\n if (!geometry.hasAttribute(attributeName)) {\n throw new Error(\n `SimpleBatchedMesh: Added geometry missing \"${attributeName}\".`,\n );\n }\n\n const srcAttribute = geometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n const dstAttribute = batchGeometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n if (\n srcAttribute.itemSize !== dstAttribute.itemSize ||\n srcAttribute.normalized !== dstAttribute.normalized\n ) {\n throw new Error(\n 'SimpleBatchedMesh: All attributes must have consistent itemSize and normalized value.',\n );\n }\n }\n }\n\n addGeometry(\n geometry: BufferGeometry,\n vertexCount = -1,\n indexCount = -1,\n ): number {\n this._initializeGeometry(geometry);\n this._validateGeometry(geometry);\n\n if (this._geometryCount >= this._maxGeometryCount) {\n throw new Error('SimpleBatchedMesh: Maximum geometry count reached.');\n }\n\n const reservedRange = {\n vertexStart: -1,\n vertexCount: -1,\n indexStart: -1,\n indexCount: -1,\n };\n\n let lastRange = null;\n const reservedRanges = this._reservedRanges;\n if (this._geometryCount !== 0) {\n lastRange = reservedRanges[reservedRanges.length - 1];\n }\n\n if (vertexCount === -1) {\n reservedRange.vertexCount = (\n geometry.getAttribute('position') as BufferAttribute\n ).count;\n } else {\n reservedRange.vertexCount = vertexCount;\n }\n\n if (lastRange === null) {\n reservedRange.vertexStart = 0;\n } else {\n reservedRange.vertexStart = lastRange.vertexStart + lastRange.vertexCount;\n }\n\n const index = geometry.getIndex();\n const hasIndex = index !== null;\n if (hasIndex) {\n if (indexCount === -1) {\n reservedRange.indexCount = index!.count;\n } else {\n reservedRange.indexCount = indexCount;\n }\n\n if (lastRange === null) {\n reservedRange.indexStart = 0;\n } else {\n reservedRange.indexStart = lastRange.indexStart + lastRange.indexCount;\n }\n }\n\n if (\n (reservedRange.indexStart !== -1 &&\n reservedRange.indexStart + reservedRange.indexCount >\n this._maxIndexCount) ||\n reservedRange.vertexStart + reservedRange.vertexCount >\n this._maxVertexCount\n ) {\n throw new Error(\n 'SimpleBatchedMesh: Reserved space request exceeds maximum buffer size.',\n );\n }\n\n this._visibility.push(true);\n this._active.push(true);\n\n const geometryId = this._geometryCount;\n this._geometryCount++;\n\n // Initialize matrix to identity\n const matricesArray = this._matricesTexture!.image.data as Float32Array;\n _identityMatrix.toArray(matricesArray, geometryId * 16);\n this._matricesTexture!.needsUpdate = true;\n\n reservedRanges.push(reservedRange);\n this._drawRanges.push({\n start: hasIndex ? reservedRange.indexStart : reservedRange.vertexStart,\n count: -1,\n });\n this._bounds.push({\n boxInitialized: false,\n box: new Box3(),\n sphereInitialized: false,\n sphere: new Sphere(),\n });\n\n // Set the batchId for all vertices of this geometry\n const idAttribute = (this.geometry as BufferGeometry).getAttribute(\n ID_ATTR_NAME,\n ) as BufferAttribute;\n for (let i = 0; i < reservedRange.vertexCount; i++) {\n idAttribute.setX(reservedRange.vertexStart + i, geometryId);\n }\n idAttribute.needsUpdate = true;\n\n // Copy geometry data\n this.setGeometryAt(geometryId, geometry);\n\n return geometryId;\n }\n\n setGeometryAt(id: number, geometry: BufferGeometry): number {\n if (id >= this._geometryCount) {\n throw new Error('SimpleBatchedMesh: Maximum geometry count reached.');\n }\n\n this._validateGeometry(geometry);\n\n const batchGeometry = this.geometry as BufferGeometry;\n const hasIndex = batchGeometry.getIndex() !== null;\n const dstIndex = batchGeometry.getIndex();\n const srcIndex = geometry.getIndex();\n const reservedRange = this._reservedRanges[id];\n\n if (\n (hasIndex && srcIndex!.count > reservedRange.indexCount) ||\n (geometry.getAttribute('position') as BufferAttribute).count >\n reservedRange.vertexCount\n ) {\n throw new Error(\n 'SimpleBatchedMesh: Reserved space not large enough for provided geometry.',\n );\n }\n\n const vertexStart = reservedRange.vertexStart;\n const vertexCount = reservedRange.vertexCount;\n\n for (const attributeName in batchGeometry.attributes) {\n if (attributeName === ID_ATTR_NAME) {\n continue;\n }\n\n const srcAttribute = geometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n const dstAttribute = batchGeometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n copyAttributeData(srcAttribute, dstAttribute, vertexStart);\n\n // Fill rest with zeroes\n const itemSize = srcAttribute.itemSize;\n for (let i = srcAttribute.count; i < vertexCount; i++) {\n const index = vertexStart + i;\n for (let c = 0; c < itemSize; c++) {\n dstAttribute.setComponent(index, c, 0);\n }\n }\n\n dstAttribute.needsUpdate = true;\n }\n\n // Copy index\n if (hasIndex && dstIndex && srcIndex) {\n const indexStart = reservedRange.indexStart;\n\n for (let i = 0; i < srcIndex.count; i++) {\n dstIndex.setX(indexStart + i, vertexStart + srcIndex.getX(i));\n }\n\n for (let i = srcIndex.count; i < reservedRange.indexCount; i++) {\n dstIndex.setX(indexStart + i, vertexStart);\n }\n\n dstIndex.needsUpdate = true;\n }\n\n // Store bounding info\n const bound = this._bounds[id];\n if (geometry.boundingBox !== null) {\n bound.box.copy(geometry.boundingBox);\n bound.boxInitialized = true;\n } else {\n bound.boxInitialized = false;\n }\n\n if (geometry.boundingSphere !== null) {\n bound.sphere.copy(geometry.boundingSphere);\n bound.sphereInitialized = true;\n } else {\n bound.sphereInitialized = false;\n }\n\n // Set draw range count\n const drawRange = this._drawRanges[id];\n const posAttr = geometry.getAttribute('position') as BufferAttribute;\n drawRange.count = hasIndex ? srcIndex!.count : posAttr.count;\n\n return id;\n }\n\n setMatrixAt(geometryId: number, matrix: Matrix4): this {\n const active = this._active;\n const matricesTexture = this._matricesTexture!;\n const matricesArray = matricesTexture.image.data as Float32Array;\n\n if (geometryId >= this._geometryCount || active[geometryId] === false) {\n return this;\n }\n\n matrix.toArray(matricesArray, geometryId * 16);\n matricesTexture.needsUpdate = true;\n\n return this;\n }\n\n getMatrixAt(geometryId: number, matrix: Matrix4): Matrix4 | null {\n const active = this._active;\n const matricesArray = this._matricesTexture!.image.data as Float32Array;\n\n if (geometryId >= this._geometryCount || active[geometryId] === false) {\n return null;\n }\n\n return matrix.fromArray(matricesArray, geometryId * 16);\n }\n\n setVisibleAt(geometryId: number, value: boolean): this {\n const visibility = this._visibility;\n const active = this._active;\n\n if (\n geometryId >= this._geometryCount ||\n active[geometryId] === false ||\n visibility[geometryId] === value\n ) {\n return this;\n }\n\n visibility[geometryId] = value;\n return this;\n }\n\n getVisibleAt(geometryId: number): boolean {\n const visibility = this._visibility;\n const active = this._active;\n\n if (geometryId >= this._geometryCount || active[geometryId] === false) {\n return false;\n }\n\n return visibility[geometryId];\n }\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,CAAC,KAAK,KAAK,EAChC;AACA,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,UAAU,CAAC,UAAU,CAAC,GAAG,KAAK;AAC9B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,YAAY,CAAC,UAAkB,EAAA;AAC7B,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW;AACnC,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO;AAE3B,QAAA,IAAI,UAAU,IAAI,IAAI,CAAC,cAAc,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,EAAE;AACrE,YAAA,OAAO,KAAK;QACd;AAEA,QAAA,OAAO,UAAU,CAAC,UAAU,CAAC;IAC/B;IAEA,OAAO,GAAA;;AACL,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AACvB,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,gBAAgB,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,OAAO,EAAE;IAClC;AACD;;;;"}
1
+ {"version":3,"file":"simple-batched-mesh.js","sources":["../../../src/visual/utils/simple-batched-mesh.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * SimpleBatchedMesh - A multiview-compatible batched mesh implementation\n *\n * This is based on the THREE.js r165 BatchedMesh approach which uses a vertex\n * attribute for batch IDs instead of gl_DrawID. This works correctly with\n * multiview rendering on Quest, where the gl_DrawID-based approach fails.\n *\n * Key differences from modern THREE.js BatchedMesh:\n * - Uses `attribute float batchId` instead of `gl_DrawID`\n * - Simpler API: each geometry is its own instance\n * - No dependency on WEBGL_multi_draw extension\n */\n\nimport {\n Box3,\n BufferAttribute,\n BufferGeometry,\n DataTexture,\n FloatType,\n Material,\n Matrix4,\n Mesh,\n RGBAFormat,\n REVISION,\n Sphere,\n} from 'three';\n\nconst ID_ATTR_NAME = 'batchId';\nconst _identityMatrix = new Matrix4();\n// Since r183, three's vertex color varying is always a vec4.\nconst VEC4_VERTEX_COLORS = parseInt(REVISION) >= 183;\n\n// Helper to copy attribute data\nfunction copyAttributeData(\n src: BufferAttribute,\n target: BufferAttribute,\n targetOffset = 0,\n) {\n const itemSize = target.itemSize;\n if (src.array.constructor !== target.array.constructor) {\n const vertexCount = src.count;\n for (let i = 0; i < vertexCount; i++) {\n for (let c = 0; c < itemSize; c++) {\n target.setComponent(i + targetOffset, c, src.getComponent(i, c));\n }\n }\n } else {\n target.array.set(src.array, targetOffset * itemSize);\n }\n target.needsUpdate = true;\n}\n\nexport class SimpleBatchedMesh extends Mesh {\n // Do NOT set isBatchedMesh = true - that triggers THREE.js's multi-draw path\n // which we don't support. Instead we handle batching entirely through material patching.\n readonly isSimpleBatchedMesh = true;\n\n private _drawRanges: Array<{ start: number; count: number }> = [];\n private _reservedRanges: Array<{\n vertexStart: number;\n vertexCount: number;\n indexStart: number;\n indexCount: number;\n }> = [];\n private _visibility: boolean[] = [];\n private _active: boolean[] = [];\n private _bounds: Array<{\n boxInitialized: boolean;\n box: Box3;\n sphereInitialized: boolean;\n sphere: Sphere;\n }> = [];\n\n private _maxGeometryCount: number;\n private _maxVertexCount: number;\n private _maxIndexCount: number;\n\n private _geometryInitialized = false;\n private _geometryCount = 0;\n\n // Matrices texture for batch transforms\n private _matricesTexture: DataTexture | null = null;\n\n constructor(\n maxGeometryCount: number,\n maxVertexCount: number,\n maxIndexCount: number = maxVertexCount * 2,\n material: Material,\n ) {\n super(new BufferGeometry(), material);\n\n this._maxGeometryCount = maxGeometryCount;\n this._maxVertexCount = maxVertexCount;\n this._maxIndexCount = maxIndexCount;\n\n this._initMatricesTexture();\n\n // Patch the material to use batchId attribute\n this._patchMaterial(material);\n }\n\n get maxGeometryCount() {\n return this._maxGeometryCount;\n }\n\n private _initMatricesTexture() {\n // Layout: 1 matrix = 4 pixels (RGBA each column)\n let size = Math.sqrt(this._maxGeometryCount * 4);\n size = Math.ceil(size / 4) * 4;\n size = Math.max(size, 4);\n\n const matricesArray = new Float32Array(size * size * 4);\n const matricesTexture = new DataTexture(\n matricesArray,\n size,\n size,\n RGBAFormat,\n FloatType,\n );\n\n this._matricesTexture = matricesTexture;\n }\n\n private _patchMaterial(material: Material) {\n // Add the batchingTexture uniform and onBeforeCompile hook\n const self = this;\n\n material.onBeforeCompile = (shader) => {\n // Add uniforms\n shader.uniforms.batchingTexture = { value: self._matricesTexture };\n\n // Inject USE_BATCHING define at the start of vertex shader\n // (THREE.js won't add it since we don't set isBatchedMesh = true)\n shader.vertexShader = '#define USE_BATCHING\\n' + shader.vertexShader;\n\n // Add batching pars to vertex shader (r165 style with attribute)\n // Includes both matrix lookup and color lookup functions\n const batchingParsVertex = `\n #ifdef USE_BATCHING\n attribute float batchId;\n uniform highp sampler2D batchingTexture;\n mat4 getBatchingMatrix( const in float i ) {\n int size = textureSize( batchingTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n #endif\n #ifdef USE_BATCHING_COLOR\n uniform sampler2D batchingColorTexture;\n vec4 getBatchingColor( const in float i ) {\n int size = textureSize( batchingColorTexture, 0 ).x;\n int j = int( i );\n int x = j % size;\n int y = j / size;\n return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n }\n #endif\n `;\n\n // Replace THREE.js batching_pars_vertex\n shader.vertexShader = shader.vertexShader.replace(\n '#include <batching_pars_vertex>',\n batchingParsVertex,\n );\n\n // Replace batching_vertex to use batchId attribute\n const batchingVertex = `\n #ifdef USE_BATCHING\n mat4 batchingMatrix = getBatchingMatrix( batchId );\n #endif\n `;\n\n shader.vertexShader = shader.vertexShader.replace(\n '#include <batching_vertex>',\n batchingVertex,\n );\n\n // Replace color_vertex to use batchId for batching color (r165 style);\n // three's own chunk uses getIndirectIndex(gl_DrawID), which we don't\n // support. vColor is a vec4 since r183 and a vec3 (vec4 with\n // USE_COLOR_ALPHA) before that.\n const colorVertex = VEC4_VERTEX_COLORS\n ? `\n #if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec4( 1.0 );\n #endif\n #ifdef USE_COLOR_ALPHA\n vColor *= color;\n #elif defined( USE_COLOR )\n vColor.rgb *= color;\n #endif\n #ifdef USE_INSTANCING_COLOR\n vColor.rgb *= instanceColor.rgb;\n #endif\n #ifdef USE_BATCHING_COLOR\n vColor *= getBatchingColor( batchId );\n #endif\n `\n : `\n #if defined( USE_COLOR_ALPHA )\n vColor = vec4( 1.0 );\n #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec3( 1.0 );\n #endif\n #ifdef USE_COLOR\n vColor *= color;\n #endif\n #ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.xyz;\n #endif\n #ifdef USE_BATCHING_COLOR\n vColor.xyz *= getBatchingColor( batchId ).xyz;\n #endif\n `;\n\n shader.vertexShader = shader.vertexShader.replace(\n '#include <color_vertex>',\n colorVertex,\n );\n };\n\n // Force material to use batching\n (material as any).batching = true;\n material.needsUpdate = true;\n }\n\n private _initializeGeometry(reference: BufferGeometry) {\n const geometry = this.geometry as BufferGeometry;\n const maxVertexCount = this._maxVertexCount;\n const maxGeometryCount = this._maxGeometryCount;\n const maxIndexCount = this._maxIndexCount;\n\n if (this._geometryInitialized === false) {\n for (const attributeName in reference.attributes) {\n const srcAttribute = reference.getAttribute(\n attributeName,\n ) as BufferAttribute;\n const { array, itemSize, normalized } = srcAttribute;\n\n const dstArray = new (array.constructor as any)(\n maxVertexCount * itemSize,\n );\n const dstAttribute = new BufferAttribute(\n dstArray,\n itemSize,\n normalized,\n );\n\n geometry.setAttribute(attributeName, dstAttribute);\n }\n\n if (reference.getIndex() !== null) {\n const indexArray =\n maxVertexCount > 65536\n ? new Uint32Array(maxIndexCount)\n : new Uint16Array(maxIndexCount);\n\n geometry.setIndex(new BufferAttribute(indexArray, 1));\n }\n\n // Add batchId attribute (the key difference from r181)\n const idArray =\n maxGeometryCount > 65536\n ? new Uint32Array(maxVertexCount)\n : new Uint16Array(maxVertexCount);\n geometry.setAttribute(ID_ATTR_NAME, new BufferAttribute(idArray, 1));\n\n this._geometryInitialized = true;\n }\n }\n\n private _validateGeometry(geometry: BufferGeometry) {\n if (geometry.getAttribute(ID_ATTR_NAME)) {\n throw new Error(\n `SimpleBatchedMesh: Geometry cannot use attribute \"${ID_ATTR_NAME}\"`,\n );\n }\n\n const batchGeometry = this.geometry as BufferGeometry;\n if (Boolean(geometry.getIndex()) !== Boolean(batchGeometry.getIndex())) {\n throw new Error(\n 'SimpleBatchedMesh: All geometries must consistently have \"index\".',\n );\n }\n\n for (const attributeName in batchGeometry.attributes) {\n if (attributeName === ID_ATTR_NAME) {\n continue;\n }\n\n if (!geometry.hasAttribute(attributeName)) {\n throw new Error(\n `SimpleBatchedMesh: Added geometry missing \"${attributeName}\".`,\n );\n }\n\n const srcAttribute = geometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n const dstAttribute = batchGeometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n if (\n srcAttribute.itemSize !== dstAttribute.itemSize ||\n srcAttribute.normalized !== dstAttribute.normalized\n ) {\n throw new Error(\n 'SimpleBatchedMesh: All attributes must have consistent itemSize and normalized value.',\n );\n }\n }\n }\n\n addGeometry(\n geometry: BufferGeometry,\n vertexCount = -1,\n indexCount = -1,\n ): number {\n this._initializeGeometry(geometry);\n this._validateGeometry(geometry);\n\n if (this._geometryCount >= this._maxGeometryCount) {\n throw new Error('SimpleBatchedMesh: Maximum geometry count reached.');\n }\n\n const reservedRange = {\n vertexStart: -1,\n vertexCount: -1,\n indexStart: -1,\n indexCount: -1,\n };\n\n let lastRange = null;\n const reservedRanges = this._reservedRanges;\n if (this._geometryCount !== 0) {\n lastRange = reservedRanges[reservedRanges.length - 1];\n }\n\n if (vertexCount === -1) {\n reservedRange.vertexCount = (\n geometry.getAttribute('position') as BufferAttribute\n ).count;\n } else {\n reservedRange.vertexCount = vertexCount;\n }\n\n if (lastRange === null) {\n reservedRange.vertexStart = 0;\n } else {\n reservedRange.vertexStart = lastRange.vertexStart + lastRange.vertexCount;\n }\n\n const index = geometry.getIndex();\n const hasIndex = index !== null;\n if (hasIndex) {\n if (indexCount === -1) {\n reservedRange.indexCount = index!.count;\n } else {\n reservedRange.indexCount = indexCount;\n }\n\n if (lastRange === null) {\n reservedRange.indexStart = 0;\n } else {\n reservedRange.indexStart = lastRange.indexStart + lastRange.indexCount;\n }\n }\n\n if (\n (reservedRange.indexStart !== -1 &&\n reservedRange.indexStart + reservedRange.indexCount >\n this._maxIndexCount) ||\n reservedRange.vertexStart + reservedRange.vertexCount >\n this._maxVertexCount\n ) {\n throw new Error(\n 'SimpleBatchedMesh: Reserved space request exceeds maximum buffer size.',\n );\n }\n\n this._visibility.push(true);\n this._active.push(true);\n\n const geometryId = this._geometryCount;\n this._geometryCount++;\n\n // Initialize matrix to identity\n const matricesArray = this._matricesTexture!.image.data as Float32Array;\n _identityMatrix.toArray(matricesArray, geometryId * 16);\n this._matricesTexture!.needsUpdate = true;\n\n reservedRanges.push(reservedRange);\n this._drawRanges.push({\n start: hasIndex ? reservedRange.indexStart : reservedRange.vertexStart,\n count: -1,\n });\n this._bounds.push({\n boxInitialized: false,\n box: new Box3(),\n sphereInitialized: false,\n sphere: new Sphere(),\n });\n\n // Set the batchId for all vertices of this geometry\n const idAttribute = (this.geometry as BufferGeometry).getAttribute(\n ID_ATTR_NAME,\n ) as BufferAttribute;\n for (let i = 0; i < reservedRange.vertexCount; i++) {\n idAttribute.setX(reservedRange.vertexStart + i, geometryId);\n }\n idAttribute.needsUpdate = true;\n\n // Copy geometry data\n this.setGeometryAt(geometryId, geometry);\n\n return geometryId;\n }\n\n setGeometryAt(id: number, geometry: BufferGeometry): number {\n if (id >= this._geometryCount) {\n throw new Error('SimpleBatchedMesh: Maximum geometry count reached.');\n }\n\n this._validateGeometry(geometry);\n\n const batchGeometry = this.geometry as BufferGeometry;\n const hasIndex = batchGeometry.getIndex() !== null;\n const dstIndex = batchGeometry.getIndex();\n const srcIndex = geometry.getIndex();\n const reservedRange = this._reservedRanges[id];\n\n if (\n (hasIndex && srcIndex!.count > reservedRange.indexCount) ||\n (geometry.getAttribute('position') as BufferAttribute).count >\n reservedRange.vertexCount\n ) {\n throw new Error(\n 'SimpleBatchedMesh: Reserved space not large enough for provided geometry.',\n );\n }\n\n const vertexStart = reservedRange.vertexStart;\n const vertexCount = reservedRange.vertexCount;\n\n for (const attributeName in batchGeometry.attributes) {\n if (attributeName === ID_ATTR_NAME) {\n continue;\n }\n\n const srcAttribute = geometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n const dstAttribute = batchGeometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n copyAttributeData(srcAttribute, dstAttribute, vertexStart);\n\n // Fill rest with zeroes\n const itemSize = srcAttribute.itemSize;\n for (let i = srcAttribute.count; i < vertexCount; i++) {\n const index = vertexStart + i;\n for (let c = 0; c < itemSize; c++) {\n dstAttribute.setComponent(index, c, 0);\n }\n }\n\n dstAttribute.needsUpdate = true;\n }\n\n // Copy index\n if (hasIndex && dstIndex && srcIndex) {\n const indexStart = reservedRange.indexStart;\n\n for (let i = 0; i < srcIndex.count; i++) {\n dstIndex.setX(indexStart + i, vertexStart + srcIndex.getX(i));\n }\n\n for (let i = srcIndex.count; i < reservedRange.indexCount; i++) {\n dstIndex.setX(indexStart + i, vertexStart);\n }\n\n dstIndex.needsUpdate = true;\n }\n\n // Store bounding info\n const bound = this._bounds[id];\n if (geometry.boundingBox !== null) {\n bound.box.copy(geometry.boundingBox);\n bound.boxInitialized = true;\n } else {\n bound.boxInitialized = false;\n }\n\n if (geometry.boundingSphere !== null) {\n bound.sphere.copy(geometry.boundingSphere);\n bound.sphereInitialized = true;\n } else {\n bound.sphereInitialized = false;\n }\n\n // Set draw range count\n const drawRange = this._drawRanges[id];\n const posAttr = geometry.getAttribute('position') as BufferAttribute;\n drawRange.count = hasIndex ? srcIndex!.count : posAttr.count;\n\n return id;\n }\n\n setMatrixAt(geometryId: number, matrix: Matrix4): this {\n const active = this._active;\n const matricesTexture = this._matricesTexture!;\n const matricesArray = matricesTexture.image.data as Float32Array;\n\n if (geometryId >= this._geometryCount || active[geometryId] === false) {\n return this;\n }\n\n matrix.toArray(matricesArray, geometryId * 16);\n matricesTexture.needsUpdate = true;\n\n return this;\n }\n\n getMatrixAt(geometryId: number, matrix: Matrix4): Matrix4 | null {\n const active = this._active;\n const matricesArray = this._matricesTexture!.image.data as Float32Array;\n\n if (geometryId >= this._geometryCount || active[geometryId] === false) {\n return null;\n }\n\n return matrix.fromArray(matricesArray, geometryId * 16);\n }\n\n setVisibleAt(geometryId: number, value: boolean): this {\n const visibility = this._visibility;\n const active = this._active;\n\n if (\n geometryId >= this._geometryCount ||\n active[geometryId] === false ||\n visibility[geometryId] === value\n ) {\n return this;\n }\n\n visibility[geometryId] = value;\n return this;\n }\n\n getVisibleAt(geometryId: number): boolean {\n const visibility = this._visibility;\n const active = this._active;\n\n if (geometryId >= this._geometryCount || active[geometryId] === false) {\n return false;\n }\n\n return visibility[geometryId];\n }\n\n dispose() {\n this.geometry.dispose();\n this._matricesTexture?.dispose();\n }\n}\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAEH;;;;;;;;;;;AAWG;AAgBH,MAAM,YAAY,GAAG,SAAS;AAC9B,MAAM,eAAe,GAAG,IAAI,OAAO,EAAE;AACrC;AACA,MAAM,kBAAkB,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,GAAG;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A,IAAA,YAAY,CAAC,UAAkB,EAAA;AAC7B,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW;AACnC,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO;AAE3B,QAAA,IAAI,UAAU,IAAI,IAAI,CAAC,cAAc,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,EAAE;AACrE,YAAA,OAAO,KAAK;QACd;AAEA,QAAA,OAAO,UAAU,CAAC,UAAU,CAAC;IAC/B;IAEA,OAAO,GAAA;;AACL,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AACvB,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,gBAAgB,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,OAAO,EAAE;IAClC;AACD;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iwsdk/xr-input",
3
- "version": "1.0.1-rc.0",
3
+ "version": "1.1.0-rc.0",
4
4
  "description": "WebXR input system with controller and hand tracking support, visual adapters, and input profiles for Three.js applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",