three-zoo 0.4.1 → 0.4.3
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/README.md +110 -0
- package/dist/BiFovCamera.d.ts +49 -0
- package/dist/Bounds.d.ts +15 -1
- package/dist/GeometryHasher.d.ts +17 -0
- package/dist/InstanceAssembler.d.ts +23 -7
- package/dist/SceneProcessor.d.ts +25 -10
- package/dist/SceneTraversal.d.ts +20 -0
- package/dist/SkinnedMeshBaker.d.ts +13 -14
- package/dist/Sun.d.ts +22 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +285 -240
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/package.json +12 -4
- package/dist/DoubleFOVCamera.d.ts +0 -7
- package/dist/Enumerator.d.ts +0 -12
- package/dist/GeometryComparator.d.ts +0 -27
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/Bounds.ts","../src/DoubleFOVCamera.ts","../src/Enumerator.ts","../src/GeometryComparator.ts","../src/InstanceAssembler.ts","../src/SceneProcessor.ts","../src/SkinnedMeshBaker.ts","../src/Sun.ts"],"sourcesContent":["import { Box3, Vector3 } from \"three\";\n\nexport class Bounds extends Box3 {\n private readonly tempVector3: Vector3 = new Vector3();\n\n public get width(): number {\n return this.max.x - this.min.x;\n }\n\n public get height(): number {\n return this.max.y - this.min.y;\n }\n\n public get depth(): number {\n return this.max.z - this.min.z;\n }\n\n public get diagonal(): number {\n this.tempVector3.subVectors(this.max, this.min);\n return this.tempVector3.length();\n }\n}\n","import { MathUtils, PerspectiveCamera } from \"three\";\n\nexport class DoubleFOVCamera extends PerspectiveCamera {\n constructor(\n public horizontalFov = 90,\n public verticalFov = 90,\n aspect = 1,\n near = 1,\n far = 1000,\n ) {\n super(verticalFov, aspect, near, far);\n }\n\n public override updateProjectionMatrix(): void {\n if (this.aspect >= 1) {\n const radians = MathUtils.degToRad(this.horizontalFov);\n this.fov = MathUtils.radToDeg(\n Math.atan(Math.tan(radians / 2) / this.aspect) * 2,\n );\n } else {\n this.fov = this.verticalFov;\n }\n\n super.updateProjectionMatrix();\n }\n}\n","import { Material, Mesh, Object3D } from \"three\";\n\ntype Constructor<T> = abstract new (...args: never[]) => T;\n\nexport class Enumerator {\n public static getObjectByName(\n object: Object3D,\n name: string,\n ): Object3D | null {\n if (object.name === name) return object;\n\n for (const child of object.children) {\n const result = Enumerator.getObjectByName(child, name);\n if (result) return result;\n }\n\n return null;\n }\n\n public static getMaterialByName(\n object: Object3D,\n name: string,\n ): Material | null {\n if (object instanceof Mesh) {\n if (Array.isArray(object.material)) {\n for (const material of object.material) {\n if (material.name === name) return material;\n }\n } else if (object.material.name === name) {\n return object.material;\n }\n }\n\n for (const child of object.children) {\n const material = Enumerator.getMaterialByName(child, name);\n if (material) return material;\n }\n\n return null;\n }\n\n public static enumerateObjectsByType<T>(\n object: Object3D,\n type: Constructor<T>,\n callback: (instance: T) => void,\n ): void {\n if (object instanceof type) {\n callback(object);\n }\n\n for (const child of object.children) {\n Enumerator.enumerateObjectsByType(child, type, callback);\n }\n }\n\n public static enumerateMaterials(\n object: Object3D,\n callback: (material: Material) => void,\n ): void {\n if (object instanceof Mesh) {\n if (Array.isArray(object.material)) {\n for (const material of object.material) {\n callback(material);\n }\n } else {\n callback(object.material);\n }\n }\n\n for (const child of object.children) {\n Enumerator.enumerateMaterials(child, callback);\n }\n }\n\n public static filterObjects(object: Object3D, name: RegExp): Object3D[] {\n let result: Object3D[] = [];\n\n if (object.name && name.test(object.name)) {\n result.push(object);\n }\n\n for (const child of object.children) {\n result = result.concat(Enumerator.filterObjects(child, name));\n }\n\n return result;\n }\n\n public static filterMaterials(object: Object3D, name: RegExp): Material[] {\n let result: Material[] = [];\n\n if (object instanceof Mesh) {\n if (Array.isArray(object.material)) {\n for (const material of object.material) {\n if (material.name && name.test(material.name)) {\n result.push(material);\n }\n }\n } else {\n if (object.material.name && name.test(object.material.name)) {\n result.push(object.material);\n }\n }\n }\n\n for (const child of object.children) {\n result = result.concat(Enumerator.filterMaterials(child, name));\n }\n\n return result;\n }\n\n public static setShadowRecursive(\n object: Object3D,\n castShadow = true,\n receiveShadow = true,\n ): void {\n if (object instanceof Mesh || \"isMesh\" in object) {\n (object as Mesh).castShadow = castShadow;\n (object as Mesh).receiveShadow = receiveShadow;\n }\n\n for (const child of object.children) {\n Enumerator.setShadowRecursive(child, castShadow, receiveShadow);\n }\n }\n}\n","import {\n BufferAttribute,\n BufferGeometry,\n InterleavedBufferAttribute,\n} from \"three\";\n\ntype AnySuitableAttribute = BufferAttribute | InterleavedBufferAttribute;\n\n/**\n * Utility class for comparing and hashing BufferGeometry instances with tolerance support.\n */\nexport class GeometryComparator {\n /**\n * Generates a consistent hash for a BufferGeometry based on its contents and tolerance.\n *\n * @param geometry - The geometry to hash\n * @param tolerance - Precision level for number comparison (values within tolerance are considered equal)\n * @returns A string hash that will be identical for geometrically equivalent geometries\n */\n public static getGeometryHash(\n geometry: BufferGeometry,\n tolerance = 1e-6,\n ): string {\n const hashParts: string[] = [];\n\n // Process attributes\n const attributes = geometry.attributes;\n const attributeNames = Object.keys(attributes).sort(); // Sort for consistent order\n\n for (const name of attributeNames) {\n const attribute = attributes[name] as AnySuitableAttribute;\n hashParts.push(\n `${name}:${attribute.itemSize}:${this.getAttributeHash(attribute, tolerance)}`,\n );\n }\n\n // Process index if present\n if (geometry.index) {\n hashParts.push(\n `index:${this.getAttributeHash(geometry.index, tolerance)}`,\n );\n }\n\n return hashParts.join(\"|\");\n }\n\n /**\n * Compares two BufferGeometry instances for approximate equality.\n * Early exit if UUIDs match (same object or cloned geometry).\n */\n public static compare(\n firstGeometry: BufferGeometry,\n secondGeometry: BufferGeometry,\n tolerance = 1e-6,\n ): boolean {\n if (firstGeometry.uuid === secondGeometry.uuid) {\n return true;\n }\n\n // Use hash comparison for consistent results\n return (\n this.getGeometryHash(firstGeometry, tolerance) ===\n this.getGeometryHash(secondGeometry, tolerance)\n );\n }\n\n /**\n * Generates a hash for a buffer attribute with tolerance.\n */\n private static getAttributeHash(\n attribute: AnySuitableAttribute,\n tolerance: number,\n ): string {\n const array = attribute.array;\n const itemSize = \"itemSize\" in attribute ? attribute.itemSize : 1;\n const hashParts: string[] = [];\n\n // Group values by their \"tolerance buckets\"\n for (let i = 0; i < array.length; i += itemSize) {\n const itemValues = [];\n for (let j = 0; j < itemSize; j++) {\n const val = array[i + j];\n // Round to nearest tolerance multiple to group similar values\n itemValues.push(Math.round(val / tolerance) * tolerance);\n }\n hashParts.push(itemValues.join(\",\"));\n }\n\n return hashParts.join(\";\");\n }\n\n /**\n * Compares two buffer attributes with tolerance.\n */\n private static compareBufferAttributes(\n firstAttribute: AnySuitableAttribute,\n secondAttribute: AnySuitableAttribute,\n tolerance: number,\n ): boolean {\n return (\n this.getAttributeHash(firstAttribute, tolerance) ===\n this.getAttributeHash(secondAttribute, tolerance)\n );\n }\n}\n\n// import {\n// BufferAttribute,\n// BufferGeometry,\n// InterleavedBufferAttribute,\n// } from \"three\";\n\n// type AnySuitableAttribute = BufferAttribute | InterleavedBufferAttribute;\n\n// /**\n// * Utility class for comparing two BufferGeometry instances with tolerance support.\n// * Checks geometry attributes (positions, normals, UVs, etc.) and indices (if present).\n// */\n// export class GeometryComparator {\n// /**\n// * Compares two BufferGeometry instances for approximate equality.\n// * Early exit if UUIDs match (same object or cloned geometry).\n// *\n// * @param firstGeometry - The first geometry to compare.\n// * @param secondGeometry - The second geometry to compare.\n// * @param tolerance - Maximum allowed difference between numeric values (default: 1e-6).\n// * @returns `true` if geometries are equivalent within tolerance, otherwise `false`.\n// */\n// public static compare(\n// firstGeometry: BufferGeometry,\n// secondGeometry: BufferGeometry,\n// tolerance = 1e-6,\n// ): boolean {\n// if (firstGeometry.uuid === secondGeometry.uuid) {\n// return true;\n// }\n\n// const firstAttributes = firstGeometry.attributes;\n// const secondAttributes = secondGeometry.attributes;\n\n// const firstAttributeNames = Object.keys(firstAttributes);\n// const secondAttributeNames = Object.keys(secondAttributes);\n\n// if (firstAttributeNames.length !== secondAttributeNames.length) {\n// return false;\n// }\n\n// for (const attributeName of firstAttributeNames) {\n// if (!secondAttributes[attributeName]) {\n// return false;\n// }\n\n// const firstAttribute = firstAttributes[\n// attributeName\n// ] as AnySuitableAttribute;\n// const secondAttribute = secondAttributes[\n// attributeName\n// ] as AnySuitableAttribute;\n\n// if (\n// firstAttribute.count !== secondAttribute.count ||\n// firstAttribute.itemSize !== secondAttribute.itemSize ||\n// !this.compareBufferAttributes(\n// firstAttribute,\n// secondAttribute,\n// tolerance,\n// )\n// ) {\n// return false;\n// }\n// }\n\n// if (firstGeometry.index || secondGeometry.index) {\n// if (!firstGeometry.index || !secondGeometry.index) {\n// return false;\n// }\n\n// if (\n// !this.compareBufferAttributes(\n// firstGeometry.index,\n// secondGeometry.index,\n// tolerance,\n// )\n// ) {\n// return false;\n// }\n// }\n\n// return true;\n// }\n\n// /**\n// * Compares two buffer attributes (or index buffers) with tolerance.\n// *\n// * @param firstAttribute - First attribute/indices to compare.\n// * @param secondAttribute - Second attribute/indices to compare.\n// * @param tolerance - Maximum allowed difference between array elements.\n// * @returns `true` if arrays are equal within tolerance, otherwise `false`.\n// */\n// private static compareBufferAttributes(\n// firstAttribute: AnySuitableAttribute,\n// secondAttribute: AnySuitableAttribute,\n// tolerance: number,\n// ): boolean {\n// const firstArray = firstAttribute.array;\n// const secondArray = secondAttribute.array;\n\n// if (firstArray.length !== secondArray.length) {\n// return false;\n// }\n\n// for (let index = 0; index < firstArray.length; index++) {\n// if (Math.abs(firstArray[index] - secondArray[index]) > tolerance) {\n// return false;\n// }\n// }\n\n// return true;\n// }\n// }\n","import { InstancedMesh, Material, Mesh, Object3D } from \"three\";\nimport { Enumerator } from \"./Enumerator\";\nimport { GeometryComparator } from \"./GeometryComparator\";\n\ninterface IMeshDescriptor {\n meshes: Mesh[];\n materials: Material[];\n castShadow: boolean;\n receiveShadow: boolean;\n}\n\ninterface IOptions {\n container: Object3D;\n filter?: (child: Mesh) => boolean;\n geometryTolerance?: number;\n}\n\nexport class InstanceAssembler {\n public static assemble(options: IOptions): void {\n const dictionary = new Map<string, IMeshDescriptor>();\n const instancedMeshes: InstancedMesh[] = [];\n const tolerance = options.geometryTolerance ?? 1e-6;\n const geometryHashCache = new Map<string, string>();\n\n Enumerator.enumerateObjectsByType(\n options.container,\n Mesh,\n (child: Mesh) => {\n if (\n child.children.length === 0 &&\n (!options.filter || options.filter(child))\n ) {\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n\n let geometryHash = geometryHashCache.get(child.geometry.uuid);\n if (!geometryHash) {\n geometryHash = GeometryComparator.getGeometryHash(\n child.geometry,\n tolerance,\n );\n geometryHashCache.set(child.geometry.uuid, geometryHash);\n }\n\n const materialKey = materials.map((m) => m.uuid).join(\",\");\n const compositeKey = `${geometryHash}|${materialKey}`;\n\n const entry = dictionary.get(compositeKey) ?? {\n meshes: [],\n materials: materials,\n castShadow: false,\n receiveShadow: false,\n };\n\n if (child.castShadow) entry.castShadow = true;\n if (child.receiveShadow) entry.receiveShadow = true;\n\n entry.meshes.push(child);\n dictionary.set(compositeKey, entry);\n }\n },\n );\n\n for (const descriptor of dictionary.values()) {\n if (descriptor.meshes.length < 2) continue;\n const { meshes, materials, castShadow, receiveShadow } = descriptor;\n\n const sortedMeshes = meshes.sort((a, b) => a.name.localeCompare(b.name));\n const defaultMesh = sortedMeshes[0];\n\n const instancedMesh = new InstancedMesh(\n defaultMesh.geometry,\n materials.length === 1 ? materials[0] : materials,\n sortedMeshes.length,\n );\n\n instancedMesh.name = defaultMesh.name;\n instancedMesh.castShadow = castShadow;\n instancedMesh.receiveShadow = receiveShadow;\n\n for (let i = 0; i < sortedMeshes.length; i++) {\n const mesh = sortedMeshes[i];\n mesh.updateWorldMatrix(true, false);\n instancedMesh.setMatrixAt(i, mesh.matrixWorld);\n instancedMesh.userData[mesh.uuid] = mesh.userData;\n }\n\n instancedMesh.instanceMatrix.needsUpdate = true;\n instancedMeshes.push(instancedMesh);\n\n for (const mesh of sortedMeshes) {\n mesh.parent?.remove(mesh);\n }\n }\n\n if (instancedMeshes.length > 0) {\n options.container.add(...instancedMeshes);\n }\n }\n}\n","import { FrontSide, Material, Mesh, Object3D } from \"three\";\nimport { Enumerator } from \"./Enumerator\";\nimport { InstanceAssembler } from \"./InstanceAssembler\";\n\ntype IPattern = string | RegExp;\n\ninterface IOptions {\n asset: Object3D;\n castShadowMeshNames?: IPattern[];\n receiveShadowMeshNames?: IPattern[];\n transparentMaterialNames?: IPattern[];\n noDepthWriteMaterialNames?: IPattern[];\n}\n\nexport class SceneProcessor {\n public static process(options: IOptions): Object3D[] {\n const container = options.asset.clone();\n InstanceAssembler.assemble({ container: container });\n\n Enumerator.enumerateMaterials(container, (material: Material) => {\n material.transparent = SceneProcessor.matchesAny(\n material.name,\n options.transparentMaterialNames,\n );\n material.depthWrite = !SceneProcessor.matchesAny(\n material.name,\n options.noDepthWriteMaterialNames,\n );\n material.side = FrontSide;\n material.forceSinglePass = true;\n material.depthTest = true;\n });\n\n Enumerator.enumerateObjectsByType(container, Mesh, (child: Mesh) => {\n child.castShadow = SceneProcessor.matchesAny(\n child.name,\n options.castShadowMeshNames,\n );\n child.receiveShadow = SceneProcessor.matchesAny(\n child.name,\n options.receiveShadowMeshNames,\n );\n });\n\n return container.children;\n }\n\n private static matchesAny(value: string, patterns: IPattern[] = []): boolean {\n return patterns.some((p) =>\n typeof p === \"string\" ? value === p : p.test(value),\n );\n }\n}\n","import {\n AnimationClip,\n AnimationMixer,\n BufferAttribute,\n Mesh,\n Object3D,\n SkinnedMesh,\n Vector3,\n} from \"three\";\n\n/**\n * Utilities for baking poses and animations from SkinnedMesh into a regular static Mesh.\n */\nexport class SkinnedMeshBaker {\n /**\n * Bakes the current pose of a SkinnedMesh into a regular geometry.\n * Transforms all vertices according to the current skeleton state.\n *\n * @param skinnedMesh - SkinnedMesh from which to bake the geometry\n * @returns A new Mesh with positions corresponding to the current bone positions\n */\n static bakePose(skinnedMesh: SkinnedMesh): Mesh {\n const bakedGeometry = skinnedMesh.geometry.clone();\n const position = bakedGeometry.attributes[\"position\"] as BufferAttribute;\n const newPositions = new Float32Array(position.count * 3);\n const target = new Vector3();\n\n for (let i = 0; i < position.count; i++) {\n target.fromBufferAttribute(position, i);\n skinnedMesh.applyBoneTransform(i, target);\n newPositions[i * 3 + 0] = target.x;\n newPositions[i * 3 + 1] = target.y;\n newPositions[i * 3 + 2] = target.z;\n }\n\n bakedGeometry.setAttribute(\n \"position\",\n new BufferAttribute(newPositions, 3),\n );\n bakedGeometry.computeVertexNormals();\n bakedGeometry.deleteAttribute(\"skinIndex\");\n bakedGeometry.deleteAttribute(\"skinWeight\");\n\n const mesh = new Mesh(bakedGeometry, skinnedMesh.material);\n mesh.name = skinnedMesh.name;\n return mesh;\n }\n\n /**\n * Bakes a SkinnedMesh in a specific pose derived from an AnimationClip at the given timestamp.\n *\n * @param armature - The parent object (typically an armature from GLTF) containing the bones\n * @param skinnedMesh - The SkinnedMesh to be baked\n * @param timeOffset - The animation time in seconds to set\n * @param clip - The animation clip\n * @returns A new Mesh with geometry matching the specified animation frame\n */\n static bakeAnimationFrame(\n armature: Object3D,\n skinnedMesh: SkinnedMesh,\n timeOffset: number,\n clip: AnimationClip,\n ): Mesh {\n const mixer = new AnimationMixer(armature);\n const action = mixer.clipAction(clip);\n action.play();\n mixer.setTime(timeOffset);\n\n armature.updateWorldMatrix(true, true);\n skinnedMesh.skeleton.update();\n\n return this.bakePose(skinnedMesh);\n }\n}\n","import {\n Box3,\n DirectionalLight,\n RGBAFormat,\n Spherical,\n Texture,\n Vector3,\n} from \"three\";\n\nexport class Sun extends DirectionalLight {\n private tempVector3D0 = new Vector3();\n private tempVector3D1 = new Vector3();\n private tempVector3D2 = new Vector3();\n private tempVector3D3 = new Vector3();\n private tempVector3D4 = new Vector3();\n private tempVector3D5 = new Vector3();\n private tempVector3D6 = new Vector3();\n private tempVector3D7 = new Vector3();\n\n private tempBox3 = new Box3();\n private tempSpherical = new Spherical();\n\n public get distance(): number {\n return this.position.length();\n }\n\n public get elevation(): number {\n return this.tempSpherical.setFromVector3(this.position).phi;\n }\n\n public get azimuth(): number {\n return this.tempSpherical.setFromVector3(this.position).theta;\n }\n\n public set distance(value: number) {\n this.tempSpherical.setFromVector3(this.position);\n this.position.setFromSphericalCoords(\n value,\n this.tempSpherical.phi,\n this.tempSpherical.theta,\n );\n }\n\n public set elevation(value: number) {\n this.tempSpherical.setFromVector3(this.position);\n this.position.setFromSphericalCoords(\n this.tempSpherical.radius,\n value,\n this.tempSpherical.theta,\n );\n }\n\n public set azimuth(value: number) {\n this.tempSpherical.setFromVector3(this.position);\n this.position.setFromSphericalCoords(\n this.tempSpherical.radius,\n this.tempSpherical.phi,\n value,\n );\n }\n\n public setShadowMapFromBox3(box3: Box3): void {\n const camera = this.shadow.camera;\n\n this.target.updateWorldMatrix(true, false);\n this.lookAt(this.target.getWorldPosition(this.tempVector3D0));\n\n this.updateWorldMatrix(true, false);\n\n const points: Vector3[] = [\n this.tempVector3D0.set(box3.min.x, box3.min.y, box3.min.z),\n this.tempVector3D1.set(box3.min.x, box3.min.y, box3.max.z),\n this.tempVector3D2.set(box3.min.x, box3.max.y, box3.min.z),\n this.tempVector3D3.set(box3.min.x, box3.max.y, box3.max.z),\n this.tempVector3D4.set(box3.max.x, box3.min.y, box3.min.z),\n this.tempVector3D5.set(box3.max.x, box3.min.y, box3.max.z),\n this.tempVector3D6.set(box3.max.x, box3.max.y, box3.min.z),\n this.tempVector3D7.set(box3.max.x, box3.max.y, box3.max.z),\n ];\n\n const inverseMatrix = this.matrixWorld.clone().invert();\n\n for (const point of points) {\n point.applyMatrix4(inverseMatrix);\n }\n\n const newBox3 = this.tempBox3.setFromPoints(points);\n\n camera.left = newBox3.min.x;\n camera.bottom = newBox3.min.y;\n camera.near = -newBox3.max.z;\n\n camera.right = newBox3.max.x;\n camera.top = newBox3.max.y;\n camera.far = -newBox3.min.z;\n\n camera.updateWorldMatrix(true, false);\n camera.updateProjectionMatrix();\n }\n\n public setDirectionFromHDR(texture: Texture, distance = 1): void {\n const data = texture.image.data;\n const width = texture.image.width;\n const height = texture.image.height;\n\n let maxLuminance = 0;\n let maxIndex = 0;\n\n const step = texture.format === RGBAFormat ? 4 : 3;\n for (let i = 0; i < data.length; i += step) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;\n if (luminance > maxLuminance) {\n maxLuminance = luminance;\n maxIndex = i;\n }\n }\n\n const pixelIndex = maxIndex / step;\n const x = pixelIndex % width;\n const y = Math.floor(pixelIndex / width);\n\n const u = x / width;\n const v = y / height;\n\n const elevation = v * Math.PI;\n const azimuth = u * -Math.PI * 2 - Math.PI / 2;\n\n this.position.setFromSphericalCoords(distance, elevation, azimuth);\n }\n}\n"],"names":[],"mappings":";;AAEM,MAAO,MAAO,SAAQ,IAAI,CAAA;AAAhC,IAAA,WAAA,GAAA;;AACmB,QAAA,IAAA,CAAA,WAAW,GAAY,IAAI,OAAO,EAAE;;AAErD,IAAA,IAAW,KAAK,GAAA;QACd,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;;AAGhC,IAAA,IAAW,MAAM,GAAA;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;;AAGhC,IAAA,IAAW,KAAK,GAAA;QACd,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;;AAGhC,IAAA,IAAW,QAAQ,GAAA;AACjB,QAAA,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAC/C,QAAA,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;;A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,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE;AAC1C,YAAA,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YACjB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACrB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACrB,YAAA,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC;AACtD,YAAA,IAAI,SAAS,GAAG,YAAY,EAAE;gBAC5B,YAAY,GAAG,SAAS;gBACxB,QAAQ,GAAG,CAAC;;;AAIhB,QAAA,MAAM,UAAU,GAAG,QAAQ,GAAG,IAAI;AAClC,QAAA,MAAM,CAAC,GAAG,UAAU,GAAG,KAAK;QAC5B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;AAExC,QAAA,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK;AACnB,QAAA,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM;AAEpB,QAAA,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE;AAC7B,QAAA,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC;QAE9C,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;;AAErE;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/BiFovCamera.ts","../src/Bounds.ts","../src/GeometryHasher.ts","../src/SceneTraversal.ts","../src/InstanceAssembler.ts","../src/SceneProcessor.ts","../src/SkinnedMeshBaker.ts","../src/Sun.ts"],"sourcesContent":["import { MathUtils, PerspectiveCamera } from \"three\";\n\nconst DEFAULT_HORIZONTAL_FOV = 90;\nconst DEFAULT_VERTICAL_FOV = 90;\nconst DEFAULT_ASPECT = 1;\nconst DEFAULT_NEAR = 1;\nconst DEFAULT_FAR = 1000;\n\nconst MIN_FOV = 1;\nconst MAX_FOV = 179;\n\n/**\n * A camera that supports independent horizontal and vertical FOV settings.\n * Extends Three.js PerspectiveCamera to allow separate control over horizontal\n * and vertical fields of view.\n */\nexport class BiFovCamera extends PerspectiveCamera {\n private horizontalFovInternal: number;\n private verticalFovInternal: number;\n\n /**\n * @param horizontalFov - Horizontal FOV in degrees (90° default)\n * @param verticalFov - Vertical FOV in degrees (90° default)\n * @param aspect - Width/height ratio (1 default)\n * @param near - Near clipping plane (1 default)\n * @param far - Far clipping plane (1000 default)\n */\n constructor(\n horizontalFov = DEFAULT_HORIZONTAL_FOV,\n verticalFov = DEFAULT_VERTICAL_FOV,\n aspect = DEFAULT_ASPECT,\n near = DEFAULT_NEAR,\n far = DEFAULT_FAR,\n ) {\n super(verticalFov, aspect, near, far);\n this.horizontalFovInternal = horizontalFov;\n this.verticalFovInternal = verticalFov;\n this.updateProjectionMatrix();\n }\n\n /** Current horizontal FOV in degrees */\n public get horizontalFov(): number {\n return this.horizontalFovInternal;\n }\n\n /** Current vertical FOV in degrees */\n public get verticalFov(): number {\n return this.verticalFovInternal;\n }\n\n /** Set horizontal FOV in degrees (clamped between 1° and 179°) */\n public set horizontalFov(value: number) {\n this.horizontalFovInternal = MathUtils.clamp(value, MIN_FOV, MAX_FOV);\n this.updateProjectionMatrix();\n }\n\n /** Set vertical FOV in degrees (clamped between 1° and 179°) */\n public set verticalFov(value: number) {\n this.verticalFovInternal = MathUtils.clamp(value, MIN_FOV, MAX_FOV);\n this.updateProjectionMatrix();\n }\n\n /**\n * Update both horizontal and vertical FOV\n * @param horizontal - Horizontal FOV in degrees\n * @param vertical - Vertical FOV in degrees\n */\n public setFov(horizontal: number, vertical: number): void {\n this.horizontalFovInternal = MathUtils.clamp(horizontal, MIN_FOV, MAX_FOV);\n this.verticalFovInternal = MathUtils.clamp(vertical, MIN_FOV, MAX_FOV);\n this.updateProjectionMatrix();\n }\n\n /**\n * Copy FOV settings from another BiFovCamera\n * @param source - Camera to copy from\n */\n public copyFovSettings(source: BiFovCamera): void {\n this.horizontalFovInternal = source.horizontalFov;\n this.verticalFovInternal = source.verticalFov;\n this.updateProjectionMatrix();\n }\n\n /**\n * Updates the projection matrix based on FOV settings and aspect ratio.\n * In landscape: preserves horizontal FOV\n * In portrait: preserves vertical FOV\n */\n public override updateProjectionMatrix(): void {\n if (this.aspect >= 1) {\n // Landscape orientation: preserve horizontal FOV\n const radians = MathUtils.degToRad(this.horizontalFovInternal);\n this.fov = MathUtils.radToDeg(\n Math.atan(Math.tan(radians / 2) / this.aspect) * 2,\n );\n } else {\n // Portrait orientation: preserve vertical FOV\n this.fov = this.verticalFovInternal;\n }\n\n super.updateProjectionMatrix();\n }\n\n /** Get actual horizontal FOV after aspect ratio adjustments */\n public getEffectiveHorizontalFov(): number {\n if (this.aspect >= 1) {\n return this.horizontalFovInternal;\n }\n const verticalRadians = MathUtils.degToRad(this.verticalFovInternal);\n return MathUtils.radToDeg(\n Math.atan(Math.tan(verticalRadians / 2) * this.aspect) * 2,\n );\n }\n\n /** Get actual vertical FOV after aspect ratio adjustments */\n public getEffectiveVerticalFov(): number {\n if (this.aspect < 1) {\n return this.verticalFovInternal;\n }\n const horizontalRadians = MathUtils.degToRad(this.horizontalFovInternal);\n return MathUtils.radToDeg(\n Math.atan(Math.tan(horizontalRadians / 2) / this.aspect) * 2,\n );\n }\n\n /** Create a clone of this camera */\n public override clone(): this {\n const camera = new BiFovCamera(\n this.horizontalFovInternal,\n this.verticalFovInternal,\n this.aspect,\n this.near,\n this.far,\n ) as this;\n\n camera.copy(this, true);\n return camera;\n }\n}\n","import type { Object3D } from \"three\";\nimport { Box3, Vector3 } from \"three\";\n\n/**\n * Box3 with additional convenience methods for width, height, depth, etc.\n */\nexport class Bounds extends Box3 {\n /** Temporary vector for calculations */\n private readonly tempVector3A: Vector3 = new Vector3();\n\n constructor(object?: Object3D) {\n super();\n if (object) {\n this.setFromObject(object);\n }\n }\n\n /** Width (x-axis length) */\n public get width(): number {\n return this.max.x - this.min.x;\n }\n\n /** Height (y-axis length) */\n public get height(): number {\n return this.max.y - this.min.y;\n }\n\n /** Depth (z-axis length) */\n public get depth(): number {\n return this.max.z - this.min.z;\n }\n\n /** Length of the box's diagonal */\n public get diagonal(): number {\n return this.tempVector3A.subVectors(this.max, this.min).length();\n }\n\n /** Volume (width * height * depth) */\n public getVolume(): number {\n return this.width * this.height * this.depth;\n }\n\n /** Surface area (sum of all six faces) */\n public getSurfaceArea(): number {\n const w = this.width;\n const h = this.height;\n const d = this.depth;\n return 2 * (w * h + h * d + d * w);\n }\n}\n","import type { BufferGeometry } from \"three\";\n\nconst POSITION_COMPONENT_COUNT = 3;\nconst NORMAL_COMPONENT_COUNT = 3;\n\n/**\n * Internal utility to identify identical geometries.\n * @internal\n */\nexport class GeometryHasher {\n /**\n * Creates a hash for a geometry based on its vertex data.\n * Vertices that differ by less than tolerance are considered the same.\n *\n * @param geometry - Geometry to hash\n * @param tolerance - How close vertices need to be to count as identical\n * @returns Hash string that's the same for matching geometries\n * @internal\n */\n public static getGeometryHash(\n geometry: BufferGeometry,\n tolerance: number,\n ): string {\n const position = geometry.attributes[\"position\"];\n\n const positionArray = position.array;\n const positionHashParts: string[] = [];\n\n // Sample vertex positions with tolerance\n for (let i = 0; i < positionArray.length; i += POSITION_COMPONENT_COUNT) {\n const x = Math.round(positionArray[i] / tolerance);\n const y = Math.round(positionArray[i + 1] / tolerance);\n const z = Math.round(positionArray[i + 2] / tolerance);\n positionHashParts.push(`${x},${y},${z}`);\n }\n\n // Hash normal data if available\n const normal = geometry.attributes[\"normal\"];\n const normalHashParts: string[] = [];\n\n const normalArray = normal.array;\n for (let i = 0; i < normalArray.length; i += NORMAL_COMPONENT_COUNT) {\n const x = Math.round(normalArray[i] / tolerance);\n const y = Math.round(normalArray[i + 1] / tolerance);\n const z = Math.round(normalArray[i + 2] / tolerance);\n normalHashParts.push(`${x},${y},${z}`);\n }\n\n // Combine position and normal hashes\n const positionHash = positionHashParts.join(\"|\");\n const normalHash = normalHashParts.join(\"|\");\n\n return `${positionHash}#${normalHash}`;\n }\n}\n","import type { Material, Object3D } from \"three\";\nimport { Mesh } from \"three\";\n\n/** Constructor type for type-safe scene traversal */\nexport type Constructor<T> = abstract new (...args: never[]) => T;\n\n/** Find and modify objects in a Three.js scene */\nexport class SceneTraversal {\n /** Find first object with exact name match */\n public static getObjectByName(\n object: Object3D,\n name: string,\n ): Object3D | null {\n if (object.name === name) {\n return object;\n }\n\n for (const child of object.children) {\n const result = SceneTraversal.getObjectByName(child, name);\n if (result) {\n return result;\n }\n }\n\n return null;\n }\n\n /** Find first material with exact name match */\n public static getMaterialByName(\n object: Object3D,\n name: string,\n ): Material | null {\n if (object instanceof Mesh) {\n if (Array.isArray(object.material)) {\n for (const material of object.material) {\n if (material.name === name) {\n return material;\n }\n }\n } else if (object.material.name === name) {\n return object.material;\n }\n }\n\n for (const child of object.children) {\n const material = SceneTraversal.getMaterialByName(child, name);\n if (material) {\n return material;\n }\n }\n\n return null;\n }\n\n /** Process all objects of a specific type */\n public static enumerateObjectsByType<T>(\n object: Object3D,\n type: Constructor<T>,\n callback: (instance: T) => void,\n ): void {\n if (object instanceof type) {\n callback(object);\n }\n\n for (const child of object.children) {\n SceneTraversal.enumerateObjectsByType(child, type, callback);\n }\n }\n\n /** Process all materials in meshes */\n public static enumerateMaterials(\n object: Object3D,\n callback: (material: Material) => void,\n ): void {\n if (object instanceof Mesh) {\n if (Array.isArray(object.material)) {\n for (const material of object.material) {\n callback(material);\n }\n } else {\n callback(object.material);\n }\n }\n\n for (const child of object.children) {\n SceneTraversal.enumerateMaterials(child, callback);\n }\n }\n\n /** Find all objects whose names match a pattern */\n public static filterObjects(object: Object3D, name: RegExp): Object3D[] {\n let result: Object3D[] = [];\n\n if (object.name && name.test(object.name)) {\n result.push(object);\n }\n\n for (const child of object.children) {\n result = result.concat(SceneTraversal.filterObjects(child, name));\n }\n\n return result;\n }\n\n /** Find all materials whose names match a pattern */\n public static filterMaterials(object: Object3D, name: RegExp): Material[] {\n let result: Material[] = [];\n\n if (object instanceof Mesh) {\n if (Array.isArray(object.material)) {\n for (const material of object.material) {\n if (material.name && name.test(material.name)) {\n result.push(material);\n }\n }\n } else {\n if (object.material.name && name.test(object.material.name)) {\n result.push(object.material);\n }\n }\n }\n\n for (const child of object.children) {\n result = result.concat(SceneTraversal.filterMaterials(child, name));\n }\n\n return result;\n }\n\n /** Set shadow properties on meshes */\n public static setShadowRecursive(\n object: Object3D,\n castShadow = true,\n receiveShadow = true,\n filter?: (object: Object3D) => boolean,\n ): void {\n if (object instanceof Mesh || \"isMesh\" in object) {\n (object as Mesh).castShadow = castShadow;\n (object as Mesh).receiveShadow = receiveShadow;\n }\n\n for (const child of object.children) {\n SceneTraversal.setShadowRecursive(\n child,\n castShadow,\n receiveShadow,\n filter,\n );\n }\n }\n}","import type { Material, Object3D } from \"three\";\nimport { InstancedMesh, Mesh } from \"three\";\nimport { GeometryHasher } from \"./GeometryHasher\";\nimport { SceneTraversal } from \"./SceneTraversal\";\n\nconst MIN_INSTANCE_COUNT = 2;\nconst DEFAULT_TOLERANCE = 1e-6;\n\n/** A group of meshes that can be instanced together */\ninterface MeshDescription {\n /** List of meshes */\n meshes: Mesh[];\n /** Materials to use */\n materials: Material[];\n /** Should cast shadows */\n castShadow: boolean;\n /** Should receive shadows */\n receiveShadow: boolean;\n}\n\n/** Configuration for instance assembly */\nexport interface InstanceAssemblerOptions {\n /** Filter which meshes to include */\n filter: (child: Mesh) => boolean;\n\n /** How close vertices need to be to count as identical */\n geometryTolerance: number;\n}\n\n/**\n * Combines identical meshes into instanced versions for better performance.\n * Meshes are considered identical if they share the same geometry and materials.\n */\nexport class InstanceAssembler {\n /**\n * Find meshes that can be instanced and combine them.\n * Only processes meshes that:\n * - Have no children\n * - Pass the filter function (if any)\n * - Share geometry with at least one other mesh\n *\n * @param container - Object containing meshes to process\n * @param options - Optional settings\n */\n public static assemble(\n container: Object3D,\n options: Partial<InstanceAssemblerOptions> = {},\n ): void {\n const dictionary = new Map<string, MeshDescription>();\n const instances: InstancedMesh[] = [];\n\n const tolerance = options.geometryTolerance ?? DEFAULT_TOLERANCE;\n const geometryHashes = new Map<string, string>();\n\n SceneTraversal.enumerateObjectsByType(container, Mesh, (child: Mesh) => {\n if (\n child.children.length === 0 &&\n (!options.filter || options.filter(child))\n ) {\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n\n let geometryHash = geometryHashes.get(child.geometry.uuid);\n if (!geometryHash) {\n geometryHash = GeometryHasher.getGeometryHash(\n child.geometry,\n tolerance,\n );\n geometryHashes.set(child.geometry.uuid, geometryHash);\n }\n\n const materialKey = materials.map((m) => m.uuid).join(\",\");\n const compositeKey = `${geometryHash}|${materialKey}`;\n\n const entry = dictionary.get(compositeKey) ?? {\n meshes: [],\n materials,\n castShadow: false,\n receiveShadow: false,\n };\n\n if (child.castShadow) {\n entry.castShadow = true;\n }\n\n if (child.receiveShadow) {\n entry.receiveShadow = true;\n }\n\n entry.meshes.push(child);\n dictionary.set(compositeKey, entry);\n }\n });\n\n for (const descriptor of dictionary.values()) {\n if (descriptor.meshes.length < MIN_INSTANCE_COUNT) {\n continue;\n }\n const { meshes, materials, castShadow, receiveShadow } = descriptor;\n\n const sortedMeshes = meshes.sort((a, b) => a.name.localeCompare(b.name));\n const defaultMesh = sortedMeshes[0];\n\n const instancedMesh = new InstancedMesh(\n defaultMesh.geometry,\n materials.length === 1 ? materials[0] : materials,\n sortedMeshes.length,\n );\n\n instancedMesh.name = defaultMesh.name;\n instancedMesh.castShadow = castShadow;\n instancedMesh.receiveShadow = receiveShadow;\n\n for (let i = 0; i < sortedMeshes.length; i++) {\n const mesh = sortedMeshes[i];\n mesh.updateWorldMatrix(true, false);\n instancedMesh.setMatrixAt(i, mesh.matrixWorld);\n instancedMesh.userData[mesh.uuid] = mesh.userData;\n }\n\n instancedMesh.instanceMatrix.needsUpdate = true;\n instances.push(instancedMesh);\n\n for (const mesh of sortedMeshes) {\n mesh.parent?.remove(mesh);\n }\n }\n\n if (instances.length > 0) {\n container.add(...instances);\n }\n }\n}\n","import type { Material, Object3D } from \"three\";\nimport { FrontSide, Mesh } from \"three\";\nimport { InstanceAssembler } from \"./InstanceAssembler\";\nimport { SceneTraversal } from \"./SceneTraversal\";\n\n/** Options for scene post-processing */\nexport interface SceneProcessorOptions {\n /** Clone the input asset before processing? */\n cloneAsset: boolean;\n\n /** Combine identical meshes into instances? */\n assembleInstances: boolean;\n\n /** Names matching these patterns will cast shadows */\n castShadowExpressions: RegExp[];\n\n /** Names matching these patterns will receive shadows */\n receiveShadwoExpressions: RegExp[];\n\n /** Names matching these patterns will be transparent */\n transparentMaterialExpressions: RegExp[];\n\n /** Names matching these patterns won't write to depth buffer */\n noDepthWriteMaterialExpressions: RegExp[];\n}\n\n/** Post-processes a scene based on name patterns */\nexport class SceneProcessor {\n /**\n * Process a scene to set up materials and shadows.\n * \n * @param asset - Scene to process\n * @param options - How to process the scene\n * @returns Processed scene root objects\n */\n public static process(\n asset: Object3D,\n options: Partial<SceneProcessorOptions>,\n ): Object3D[] {\n const container = options.cloneAsset !== false ? asset.clone() : asset;\n\n if (options.assembleInstances !== false) {\n InstanceAssembler.assemble(container);\n }\n\n SceneTraversal.enumerateMaterials(container, (material: Material) => {\n material.transparent = SceneProcessor.matchesAny(\n material.name,\n options.transparentMaterialExpressions,\n );\n material.depthWrite = !SceneProcessor.matchesAny(\n material.name,\n options.noDepthWriteMaterialExpressions,\n );\n material.side = FrontSide;\n material.forceSinglePass = true;\n material.depthTest = true;\n });\n\n SceneTraversal.enumerateObjectsByType(container, Mesh, (child: Mesh) => {\n child.castShadow = SceneProcessor.matchesAny(\n child.name,\n options.castShadowExpressions,\n );\n child.receiveShadow = SceneProcessor.matchesAny(\n child.name,\n options.receiveShadwoExpressions,\n );\n });\n\n return container.children;\n }\n\n /** Does the string match any of the patterns? */\n private static matchesAny(\n value: string,\n expressions: RegExp[] = [],\n ): boolean {\n return expressions.some((p) => p.test(value));\n }\n}","import type { AnimationClip, Object3D, SkinnedMesh } from \"three\";\nimport { AnimationMixer, BufferAttribute, Mesh, Vector3 } from \"three\";\n\n/** Number of components per vertex */\nconst COMPONENT_COUNT = 3;\n\n/** Convert skinned meshes to regular static meshes */\nexport class SkinnedMeshBaker {\n /**\n * Convert a skinned mesh to a regular mesh in its current pose.\n * The resulting mesh will have no bones but look identical.\n * \n * @param skinnedMesh - Mesh to convert\n * @returns Static mesh with baked vertex positions\n */\n public static bakePose(skinnedMesh: SkinnedMesh): Mesh {\n const bakedGeometry = skinnedMesh.geometry.clone();\n const position = bakedGeometry.attributes[\"position\"] as BufferAttribute;\n const newPositions = new Float32Array(position.count * COMPONENT_COUNT);\n const target = new Vector3();\n\n for (let i = 0; i < position.count; i++) {\n target.fromBufferAttribute(position, i);\n skinnedMesh.applyBoneTransform(i, target);\n newPositions[i * COMPONENT_COUNT + 0] = target.x;\n newPositions[i * COMPONENT_COUNT + 1] = target.y;\n newPositions[i * COMPONENT_COUNT + 2] = target.z;\n }\n\n bakedGeometry.setAttribute(\n \"position\",\n new BufferAttribute(newPositions, COMPONENT_COUNT),\n );\n bakedGeometry.computeVertexNormals();\n bakedGeometry.deleteAttribute(\"skinIndex\");\n bakedGeometry.deleteAttribute(\"skinWeight\");\n\n const mesh = new Mesh(bakedGeometry, skinnedMesh.material);\n mesh.name = skinnedMesh.name;\n return mesh;\n }\n\n /**\n * Bake a single frame from an animation into a static mesh.\n * \n * @param armature - Root object with bones (usually from GLTF)\n * @param skinnedMesh - Mesh to convert\n * @param timeOffset - Time in seconds within the animation\n * @param clip - Animation to get the pose from\n * @returns Static mesh with baked vertex positions\n */\n public static bakeAnimationFrame(\n armature: Object3D,\n skinnedMesh: SkinnedMesh,\n timeOffset: number,\n clip: AnimationClip,\n ): Mesh {\n const mixer = new AnimationMixer(armature);\n const action = mixer.clipAction(clip);\n action.play();\n mixer.setTime(timeOffset);\n\n armature.updateWorldMatrix(true, true);\n skinnedMesh.skeleton.update();\n\n return this.bakePose(skinnedMesh);\n }\n}","import type { Texture } from \"three\";\nimport { Box3, DirectionalLight, RGBAFormat, Spherical, Vector3 } from \"three\";\n\nconst RGBA_CHANNEL_COUNT = 4;\nconst RGB_CHANNEL_COUNT = 3;\n\nconst LUMINANCE_R = 0.2126;\nconst LUMINANCE_G = 0.7152;\nconst LUMINANCE_B = 0.0722;\n\n/** A directional light with spherical positioning controls */\nexport class Sun extends DirectionalLight {\n /** Internal vectors to avoid garbage collection */\n private readonly tempVector3D0 = new Vector3();\n private readonly tempVector3D1 = new Vector3();\n private readonly tempVector3D2 = new Vector3();\n private readonly tempVector3D3 = new Vector3();\n private readonly tempVector3D4 = new Vector3();\n private readonly tempVector3D5 = new Vector3();\n private readonly tempVector3D6 = new Vector3();\n private readonly tempVector3D7 = new Vector3();\n private readonly tempBox3 = new Box3();\n private readonly tempSpherical = new Spherical();\n\n /** Distance from the light to its target */\n public get distance(): number {\n return this.position.length();\n }\n\n /** Vertical angle from the ground in radians */\n public get elevation(): number {\n return this.tempSpherical.setFromVector3(this.position).phi;\n }\n\n /** Horizontal angle around the target in radians */\n public get azimuth(): number {\n return this.tempSpherical.setFromVector3(this.position).theta;\n }\n\n /** Set distance while keeping current angles */\n public set distance(value: number) {\n this.tempSpherical.setFromVector3(this.position);\n this.position.setFromSphericalCoords(\n value,\n this.tempSpherical.phi,\n this.tempSpherical.theta,\n );\n }\n\n /** Set elevation while keeping current distance and azimuth */\n public set elevation(value: number) {\n this.tempSpherical.setFromVector3(this.position);\n this.position.setFromSphericalCoords(\n this.tempSpherical.radius,\n value,\n this.tempSpherical.theta,\n );\n }\n\n /** Set azimuth while keeping current distance and elevation */\n public set azimuth(value: number) {\n this.tempSpherical.setFromVector3(this.position);\n this.position.setFromSphericalCoords(\n this.tempSpherical.radius,\n this.tempSpherical.phi,\n value,\n );\n }\n\n /** Configure shadows to cover all corners of a bounding box */\n public setShadowMapFromBox3(box3: Box3): void {\n const camera = this.shadow.camera;\n\n this.target.updateWorldMatrix(true, false);\n this.lookAt(this.target.getWorldPosition(this.tempVector3D0));\n\n this.updateWorldMatrix(true, false);\n\n const points: Vector3[] = [\n this.tempVector3D0.set(box3.min.x, box3.min.y, box3.min.z),\n this.tempVector3D1.set(box3.min.x, box3.min.y, box3.max.z),\n this.tempVector3D2.set(box3.min.x, box3.max.y, box3.min.z),\n this.tempVector3D3.set(box3.min.x, box3.max.y, box3.max.z),\n this.tempVector3D4.set(box3.max.x, box3.min.y, box3.min.z),\n this.tempVector3D5.set(box3.max.x, box3.min.y, box3.max.z),\n this.tempVector3D6.set(box3.max.x, box3.max.y, box3.min.z),\n this.tempVector3D7.set(box3.max.x, box3.max.y, box3.max.z),\n ];\n\n const inverseMatrix = this.matrixWorld.clone().invert();\n\n for (const point of points) {\n point.applyMatrix4(inverseMatrix);\n }\n\n const newBox3 = this.tempBox3.setFromPoints(points);\n\n camera.left = newBox3.min.x;\n camera.bottom = newBox3.min.y;\n camera.near = -newBox3.max.z;\n\n camera.right = newBox3.max.x;\n camera.top = newBox3.max.y;\n camera.far = -newBox3.min.z;\n\n camera.updateWorldMatrix(true, false);\n camera.updateProjectionMatrix();\n }\n\n /** Set light direction based on brightest point in an HDR texture */\n public setDirectionFromHDR(texture: Texture, distance = 1): void {\n const data = texture.image.data;\n const width = texture.image.width;\n const height = texture.image.height;\n\n let maxLuminance = 0;\n let maxIndex = 0;\n\n // Find brightest pixel\n\n const step =\n texture.format === RGBAFormat ? RGBA_CHANNEL_COUNT : RGB_CHANNEL_COUNT;\n for (let i = 0; i < data.length; i += step) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const luminance = LUMINANCE_R * r + LUMINANCE_G * g + LUMINANCE_B * b;\n if (luminance > maxLuminance) {\n maxLuminance = luminance;\n maxIndex = i;\n }\n }\n\n // Convert to spherical coordinates\n const pixelIndex = maxIndex / step;\n const x = pixelIndex % width;\n const y = Math.floor(pixelIndex / width);\n\n const u = x / width;\n const v = y / height;\n\n const elevation = v * Math.PI;\n const azimuth = u * -Math.PI * 2 - Math.PI / 2;\n\n this.position.setFromSphericalCoords(distance, elevation, azimuth);\n }\n}\n"],"names":[],"mappings":";;AAEA,MAAM,sBAAsB,GAAG,EAAE;AACjC,MAAM,oBAAoB,GAAG,EAAE;AAC/B,MAAM,cAAc,GAAG,CAAC;AACxB,MAAM,YAAY,GAAG,CAAC;AACtB,MAAM,WAAW,GAAG,IAAI;AAExB,MAAM,OAAO,GAAG,CAAC;AACjB,MAAM,OAAO,GAAG,GAAG;AAEnB;;;;AAIG;AACG,MAAO,WAAY,SAAQ,iBAAiB,CAAA;AAIhD;;;;;;AAMG;AACH,IAAA,WAAA,CACE,aAAa,GAAG,sBAAsB,EACtC,WAAW,GAAG,oBAAoB,EAClC,MAAM,GAAG,cAAc,EACvB,IAAI,GAAG,YAAY,EACnB,GAAG,GAAG,WAAW,EAAA;QAEjB,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC;AACrC,QAAA,IAAI,CAAC,qBAAqB,GAAG,aAAa;AAC1C,QAAA,IAAI,CAAC,mBAAmB,GAAG,WAAW;QACtC,IAAI,CAAC,sBAAsB,EAAE;;;AAI/B,IAAA,IAAW,aAAa,GAAA;QACtB,OAAO,IAAI,CAAC,qBAAqB;;;AAInC,IAAA,IAAW,WAAW,GAAA;QACpB,OAAO,IAAI,CAAC,mBAAmB;;;IAIjC,IAAW,aAAa,CAAC,KAAa,EAAA;AACpC,QAAA,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC;QACrE,IAAI,CAAC,sBAAsB,EAAE;;;IAI/B,IAAW,WAAW,CAAC,KAAa,EAAA;AAClC,QAAA,IAAI,CA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AAA,MAAM,UAAU,GAAG,QAAQ,GAAG,IAAI;AAClC,QAAA,MAAM,CAAC,GAAG,UAAU,GAAG,KAAK;QAC5B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;AAExC,QAAA,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK;AACnB,QAAA,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM;AAEpB,QAAA,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE;AAC7B,QAAA,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC;QAE9C,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;;AAErE;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{PerspectiveCamera as t,MathUtils as s,Box3 as e,Vector3 as i,Mesh as h,InstancedMesh as n,FrontSide as r,BufferAttribute as o,AnimationMixer as a,DirectionalLight as c,Spherical as f,RGBAFormat as l}from"three";const u=179;class w extends t{constructor(t=90,s=90,e=1,i=1,h=1e3){super(s,e,i,h),this.horizontalFovInternal=t,this.verticalFovInternal=s,this.updateProjectionMatrix()}get horizontalFov(){return this.horizontalFovInternal}get verticalFov(){return this.verticalFovInternal}set horizontalFov(t){this.horizontalFovInternal=s.clamp(t,1,u),this.updateProjectionMatrix()}set verticalFov(t){this.verticalFovInternal=s.clamp(t,1,u),this.updateProjectionMatrix()}setFov(t,e){this.horizontalFovInternal=s.clamp(t,1,u),this.verticalFovInternal=s.clamp(e,1,u),this.updateProjectionMatrix()}copyFovSettings(t){this.horizontalFovInternal=t.horizontalFov,this.verticalFovInternal=t.verticalFov,this.updateProjectionMatrix()}updateProjectionMatrix(){if(this.aspect>=1){const t=s.degToRad(this.horizontalFovInternal);this.fov=s.radToDeg(2*Math.atan(Math.tan(t/2)/this.aspect))}else this.fov=this.verticalFovInternal;super.updateProjectionMatrix()}getEffectiveHorizontalFov(){if(this.aspect>=1)return this.horizontalFovInternal;const t=s.degToRad(this.verticalFovInternal);return s.radToDeg(2*Math.atan(Math.tan(t/2)*this.aspect))}getEffectiveVerticalFov(){if(this.aspect<1)return this.verticalFovInternal;const t=s.degToRad(this.horizontalFovInternal);return s.radToDeg(2*Math.atan(Math.tan(t/2)/this.aspect))}clone(){const t=new w(this.horizontalFovInternal,this.verticalFovInternal,this.aspect,this.near,this.far);return t.copy(this,!0),t}}class M extends e{constructor(t){super(),this.tempVector3A=new i,t&&this.setFromObject(t)}get width(){return this.max.x-this.min.x}get height(){return this.max.y-this.min.y}get depth(){return this.max.z-this.min.z}get diagonal(){return this.tempVector3A.subVectors(this.max,this.min).length()}getVolume(){return this.width*this.height*this.depth}getSurfaceArea(){const t=this.width,s=this.height,e=this.depth;return 2*(t*s+s*e+e*t)}}class v{static getGeometryHash(t,s){const e=t.attributes.position.array,i=[];for(let t=0;t<e.length;t+=3)i.push(`${Math.round(e[t]/s)},${Math.round(e[t+1]/s)},${Math.round(e[t+2]/s)}`);const h=[],n=t.attributes.normal.array;for(let t=0;t<n.length;t+=3)h.push(`${Math.round(n[t]/s)},${Math.round(n[t+1]/s)},${Math.round(n[t+2]/s)}`);return`${i.join("|")}#${h.join("|")}`}}class g{static getObjectByName(t,s){if(t.name===s)return t;for(const e of t.children){const t=g.getObjectByName(e,s);if(t)return t}return null}static getMaterialByName(t,s){if(t instanceof h)if(Array.isArray(t.material)){for(const e of t.material)if(e.name===s)return e}else if(t.material.name===s)return t.material;for(const e of t.children){const t=g.getMaterialByName(e,s);if(t)return t}return null}static enumerateObjectsByType(t,s,e){t instanceof s&&e(t);for(const i of t.children)g.enumerateObjectsByType(i,s,e)}static enumerateMaterials(t,s){if(t instanceof h)if(Array.isArray(t.material))for(const e of t.material)s(e);else s(t.material);for(const e of t.children)g.enumerateMaterials(e,s)}static filterObjects(t,s){let e=[];t.name&&s.test(t.name)&&e.push(t);for(const i of t.children)e=e.concat(g.filterObjects(i,s));return e}static filterMaterials(t,s){let e=[];if(t instanceof h)if(Array.isArray(t.material))for(const i of t.material)i.name&&s.test(i.name)&&e.push(i);else t.material.name&&s.test(t.material.name)&&e.push(t.material);for(const i of t.children)e=e.concat(g.filterMaterials(i,s));return e}static setShadowRecursive(t,s=!0,e=!0,i){(t instanceof h||"isMesh"in t)&&(t.castShadow=s,t.receiveShadow=e);for(const h of t.children)g.setShadowRecursive(h,s,e,i)}}class m{static assemble(t,s={}){var e,i;const r=new Map,o=[],a=null!==(e=s.geometryTolerance)&&void 0!==e?e:1e-6,c=new Map;g.enumerateObjectsByType(t,h,(t=>{var e;if(0===t.children.length&&(!s.filter||s.filter(t))){const s=Array.isArray(t.material)?t.material:[t.material];let i=c.get(t.geometry.uuid);i||(i=v.getGeometryHash(t.geometry,a),c.set(t.geometry.uuid,i));const h=`${i}|${s.map((t=>t.uuid)).join(",")}`,n=null!==(e=r.get(h))&&void 0!==e?e:{meshes:[],materials:s,castShadow:!1,receiveShadow:!1};t.castShadow&&(n.castShadow=!0),t.receiveShadow&&(n.receiveShadow=!0),n.meshes.push(t),r.set(h,n)}}));for(const t of r.values()){if(t.meshes.length<2)continue;const{meshes:s,materials:e,castShadow:h,receiveShadow:r}=t,a=s.sort(((t,s)=>t.name.localeCompare(s.name))),c=a[0],f=new n(c.geometry,1===e.length?e[0]:e,a.length);f.name=c.name,f.castShadow=h,f.receiveShadow=r;for(let t=0;t<a.length;t++){const s=a[t];s.updateWorldMatrix(!0,!1),f.setMatrixAt(t,s.matrixWorld),f.userData[s.uuid]=s.userData}f.instanceMatrix.needsUpdate=!0,o.push(f);for(const t of a)null===(i=t.parent)||void 0===i||i.remove(t)}o.length>0&&t.add(...o)}}class d{static process(t,s){const e=!1!==s.cloneAsset?t.clone():t;return!1!==s.assembleInstances&&m.assemble(e),g.enumerateMaterials(e,(t=>{t.transparent=d.matchesAny(t.name,s.transparentMaterialExpressions),t.depthWrite=!d.matchesAny(t.name,s.noDepthWriteMaterialExpressions),t.side=r,t.forceSinglePass=!0,t.depthTest=!0})),g.enumerateObjectsByType(e,h,(t=>{t.castShadow=d.matchesAny(t.name,s.castShadowExpressions),t.receiveShadow=d.matchesAny(t.name,s.receiveShadwoExpressions)})),e.children}static matchesAny(t,s=[]){return s.some((s=>s.test(t)))}}class p{static bakePose(t){const s=t.geometry.clone(),e=s.attributes.position,n=new Float32Array(3*e.count),r=new i;for(let s=0;s<e.count;s++)r.fromBufferAttribute(e,s),t.applyBoneTransform(s,r),n[3*s+0]=r.x,n[3*s+1]=r.y,n[3*s+2]=r.z;s.setAttribute("position",new o(n,3)),s.computeVertexNormals(),s.deleteAttribute("skinIndex"),s.deleteAttribute("skinWeight");const a=new h(s,t.material);return a.name=t.name,a}static bakeAnimationFrame(t,s,e,i){const h=new a(t);return h.clipAction(i).play(),h.setTime(e),t.updateWorldMatrix(!0,!0),s.skeleton.update(),this.bakePose(s)}}class y extends c{constructor(){super(...arguments),this.tempVector3D0=new i,this.tempVector3D1=new i,this.tempVector3D2=new i,this.tempVector3D3=new i,this.tempVector3D4=new i,this.tempVector3D5=new i,this.tempVector3D6=new i,this.tempVector3D7=new i,this.tempBox3=new e,this.tempSpherical=new f}get distance(){return this.position.length()}get elevation(){return this.tempSpherical.setFromVector3(this.position).phi}get azimuth(){return this.tempSpherical.setFromVector3(this.position).theta}set distance(t){this.tempSpherical.setFromVector3(this.position),this.position.setFromSphericalCoords(t,this.tempSpherical.phi,this.tempSpherical.theta)}set elevation(t){this.tempSpherical.setFromVector3(this.position),this.position.setFromSphericalCoords(this.tempSpherical.radius,t,this.tempSpherical.theta)}set azimuth(t){this.tempSpherical.setFromVector3(this.position),this.position.setFromSphericalCoords(this.tempSpherical.radius,this.tempSpherical.phi,t)}setShadowMapFromBox3(t){const s=this.shadow.camera;this.target.updateWorldMatrix(!0,!1),this.lookAt(this.target.getWorldPosition(this.tempVector3D0)),this.updateWorldMatrix(!0,!1);const e=[this.tempVector3D0.set(t.min.x,t.min.y,t.min.z),this.tempVector3D1.set(t.min.x,t.min.y,t.max.z),this.tempVector3D2.set(t.min.x,t.max.y,t.min.z),this.tempVector3D3.set(t.min.x,t.max.y,t.max.z),this.tempVector3D4.set(t.max.x,t.min.y,t.min.z),this.tempVector3D5.set(t.max.x,t.min.y,t.max.z),this.tempVector3D6.set(t.max.x,t.max.y,t.min.z),this.tempVector3D7.set(t.max.x,t.max.y,t.max.z)],i=this.matrixWorld.clone().invert();for(const t of e)t.applyMatrix4(i);const h=this.tempBox3.setFromPoints(e);s.left=h.min.x,s.bottom=h.min.y,s.near=-h.max.z,s.right=h.max.x,s.top=h.max.y,s.far=-h.min.z,s.updateWorldMatrix(!0,!1),s.updateProjectionMatrix()}setDirectionFromHDR(t,s=1){const e=t.image.data,i=t.image.width,h=t.image.height;let n=0,r=0;const o=t.format===l?4:3;for(let t=0;t<e.length;t+=o){const s=.2126*e[t]+.7152*e[t+1]+.0722*e[t+2];s>n&&(n=s,r=t)}const a=r/o,c=a%i;this.position.setFromSphericalCoords(s,Math.floor(a/i)/h*Math.PI,c/i*-Math.PI*2-Math.PI/2)}}export{w as BiFovCamera,M as Bounds,m as InstanceAssembler,d as SceneProcessor,g as SceneTraversal,p as SkinnedMeshBaker,y as Sun};
|
|
2
|
+
//# sourceMappingURL=index.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.min.js","sources":["../src/BiFovCamera.ts","../src/Bounds.ts","../src/GeometryHasher.ts","../src/SceneTraversal.ts","../src/InstanceAssembler.ts","../src/SceneProcessor.ts","../src/SkinnedMeshBaker.ts","../src/Sun.ts"],"sourcesContent":["import { MathUtils, PerspectiveCamera } from \"three\";\n\nconst DEFAULT_HORIZONTAL_FOV = 90;\nconst DEFAULT_VERTICAL_FOV = 90;\nconst DEFAULT_ASPECT = 1;\nconst DEFAULT_NEAR = 1;\nconst DEFAULT_FAR = 1000;\n\nconst MIN_FOV = 1;\nconst MAX_FOV = 179;\n\n/**\n * A camera that supports independent horizontal and vertical FOV settings.\n * Extends Three.js PerspectiveCamera to allow separate control over horizontal\n * and vertical fields of view.\n */\nexport class BiFovCamera extends PerspectiveCamera {\n private horizontalFovInternal: number;\n private verticalFovInternal: number;\n\n /**\n * @param horizontalFov - Horizontal FOV in degrees (90° default)\n * @param verticalFov - Vertical FOV in degrees (90° default)\n * @param aspect - Width/height ratio (1 default)\n * @param near - Near clipping plane (1 default)\n * @param far - Far clipping plane (1000 default)\n */\n constructor(\n horizontalFov = DEFAULT_HORIZONTAL_FOV,\n verticalFov = DEFAULT_VERTICAL_FOV,\n aspect = DEFAULT_ASPECT,\n near = DEFAULT_NEAR,\n far = DEFAULT_FAR,\n ) {\n super(verticalFov, aspect, near, far);\n this.horizontalFovInternal = horizontalFov;\n this.verticalFovInternal = verticalFov;\n this.updateProjectionMatrix();\n }\n\n /** Current horizontal FOV in degrees */\n public get horizontalFov(): number {\n return this.horizontalFovInternal;\n }\n\n /** Current vertical FOV in degrees */\n public get verticalFov(): number {\n return this.verticalFovInternal;\n }\n\n /** Set horizontal FOV in degrees (clamped between 1° and 179°) */\n public set horizontalFov(value: number) {\n this.horizontalFovInternal = MathUtils.clamp(value, MIN_FOV, MAX_FOV);\n this.updateProjectionMatrix();\n }\n\n /** Set vertical FOV in degrees (clamped between 1° and 179°) */\n public set verticalFov(value: number) {\n this.verticalFovInternal = MathUtils.clamp(value, MIN_FOV, MAX_FOV);\n this.updateProjectionMatrix();\n }\n\n /**\n * Update both horizontal and vertical FOV\n * @param horizontal - Horizontal FOV in degrees\n * @param vertical - Vertical FOV in degrees\n */\n public setFov(horizontal: number, vertical: number): void {\n this.horizontalFovInternal = MathUtils.clamp(horizontal, MIN_FOV, MAX_FOV);\n this.verticalFovInternal = MathUtils.clamp(vertical, MIN_FOV, MAX_FOV);\n this.updateProjectionMatrix();\n }\n\n /**\n * Copy FOV settings from another BiFovCamera\n * @param source - Camera to copy from\n */\n public copyFovSettings(source: BiFovCamera): void {\n this.horizontalFovInternal = source.horizontalFov;\n this.verticalFovInternal = source.verticalFov;\n this.updateProjectionMatrix();\n }\n\n /**\n * Updates the projection matrix based on FOV settings and aspect ratio.\n * In landscape: preserves horizontal FOV\n * In portrait: preserves vertical FOV\n */\n public override updateProjectionMatrix(): void {\n if (this.aspect >= 1) {\n // Landscape orientation: preserve horizontal FOV\n const radians = MathUtils.degToRad(this.horizontalFovInternal);\n this.fov = MathUtils.radToDeg(\n Math.atan(Math.tan(radians / 2) / this.aspect) * 2,\n );\n } else {\n // Portrait orientation: preserve vertical FOV\n this.fov = this.verticalFovInternal;\n }\n\n super.updateProjectionMatrix();\n }\n\n /** Get actual horizontal FOV after aspect ratio adjustments */\n public getEffectiveHorizontalFov(): number {\n if (this.aspect >= 1) {\n return this.horizontalFovInternal;\n }\n const verticalRadians = MathUtils.degToRad(this.verticalFovInternal);\n return MathUtils.radToDeg(\n Math.atan(Math.tan(verticalRadians / 2) * this.aspect) * 2,\n );\n }\n\n /** Get actual vertical FOV after aspect ratio adjustments */\n public getEffectiveVerticalFov(): number {\n if (this.aspect < 1) {\n return this.verticalFovInternal;\n }\n const horizontalRadians = MathUtils.degToRad(this.horizontalFovInternal);\n return MathUtils.radToDeg(\n Math.atan(Math.tan(horizontalRadians / 2) / this.aspect) * 2,\n );\n }\n\n /** Create a clone of this camera */\n public override clone(): this {\n const camera = new BiFovCamera(\n this.horizontalFovInternal,\n this.verticalFovInternal,\n this.aspect,\n this.near,\n this.far,\n ) as this;\n\n camera.copy(this, true);\n return camera;\n }\n}\n","import type { Object3D } from \"three\";\nimport { Box3, Vector3 } from \"three\";\n\n/**\n * Box3 with additional convenience methods for width, height, depth, etc.\n */\nexport class Bounds extends Box3 {\n /** Temporary vector for calculations */\n private readonly tempVector3A: Vector3 = new Vector3();\n\n constructor(object?: Object3D) {\n super();\n if (object) {\n this.setFromObject(object);\n }\n }\n\n /** Width (x-axis length) */\n public get width(): number {\n return this.max.x - this.min.x;\n }\n\n /** Height (y-axis length) */\n public get height(): number {\n return this.max.y - this.min.y;\n }\n\n /** Depth (z-axis length) */\n public get depth(): number {\n return this.max.z - this.min.z;\n }\n\n /** Length of the box's diagonal */\n public get diagonal(): number {\n return this.tempVector3A.subVectors(this.max, this.min).length();\n }\n\n /** Volume (width * height * depth) */\n public getVolume(): number {\n return this.width * this.height * this.depth;\n }\n\n /** Surface area (sum of all six faces) */\n public getSurfaceArea(): number {\n const w = this.width;\n const h = this.height;\n const d = this.depth;\n return 2 * (w * h + h * d + d * w);\n }\n}\n","import type { BufferGeometry } from \"three\";\n\nconst POSITION_COMPONENT_COUNT = 3;\nconst NORMAL_COMPONENT_COUNT = 3;\n\n/**\n * Internal utility to identify identical geometries.\n * @internal\n */\nexport class GeometryHasher {\n /**\n * Creates a hash for a geometry based on its vertex data.\n * Vertices that differ by less than tolerance are considered the same.\n *\n * @param geometry - Geometry to hash\n * @param tolerance - How close vertices need to be to count as identical\n * @returns Hash string that's the same for matching geometries\n * @internal\n */\n public static getGeometryHash(\n geometry: BufferGeometry,\n tolerance: number,\n ): string {\n const position = geometry.attributes[\"position\"];\n\n const positionArray = position.array;\n const positionHashParts: string[] = [];\n\n // Sample vertex positions with tolerance\n for (let i = 0; i < positionArray.length; i += POSITION_COMPONENT_COUNT) {\n const x = Math.round(positionArray[i] / tolerance);\n const y = Math.round(positionArray[i + 1] / tolerance);\n const z = Math.round(positionArray[i + 2] / tolerance);\n positionHashParts.push(`${x},${y},${z}`);\n }\n\n // Hash normal data if available\n const normal = geometry.attributes[\"normal\"];\n const normalHashParts: string[] = [];\n\n const normalArray = normal.array;\n for (let i = 0; i < normalArray.length; i += NORMAL_COMPONENT_COUNT) {\n const x = Math.round(normalArray[i] / tolerance);\n const y = Math.round(normalArray[i + 1] / tolerance);\n const z = Math.round(normalArray[i + 2] / tolerance);\n normalHashParts.push(`${x},${y},${z}`);\n }\n\n // Combine position and normal hashes\n const positionHash = positionHashParts.join(\"|\");\n const normalHash = normalHashParts.join(\"|\");\n\n return `${positionHash}#${normalHash}`;\n }\n}\n","import type { Material, Object3D } from \"three\";\nimport { Mesh } from \"three\";\n\n/** Constructor type for type-safe scene traversal */\nexport type Constructor<T> = abstract new (...args: never[]) => T;\n\n/** Find and modify objects in a Three.js scene */\nexport class SceneTraversal {\n /** Find first object with exact name match */\n public static getObjectByName(\n object: Object3D,\n name: string,\n ): Object3D | null {\n if (object.name === name) {\n return object;\n }\n\n for (const child of object.children) {\n const result = SceneTraversal.getObjectByName(child, name);\n if (result) {\n return result;\n }\n }\n\n return null;\n }\n\n /** Find first material with exact name match */\n public static getMaterialByName(\n object: Object3D,\n name: string,\n ): Material | null {\n if (object instanceof Mesh) {\n if (Array.isArray(object.material)) {\n for (const material of object.material) {\n if (material.name === name) {\n return material;\n }\n }\n } else if (object.material.name === name) {\n return object.material;\n }\n }\n\n for (const child of object.children) {\n const material = SceneTraversal.getMaterialByName(child, name);\n if (material) {\n return material;\n }\n }\n\n return null;\n }\n\n /** Process all objects of a specific type */\n public static enumerateObjectsByType<T>(\n object: Object3D,\n type: Constructor<T>,\n callback: (instance: T) => void,\n ): void {\n if (object instanceof type) {\n callback(object);\n }\n\n for (const child of object.children) {\n SceneTraversal.enumerateObjectsByType(child, type, callback);\n }\n }\n\n /** Process all materials in meshes */\n public static enumerateMaterials(\n object: Object3D,\n callback: (material: Material) => void,\n ): void {\n if (object instanceof Mesh) {\n if (Array.isArray(object.material)) {\n for (const material of object.material) {\n callback(material);\n }\n } else {\n callback(object.material);\n }\n }\n\n for (const child of object.children) {\n SceneTraversal.enumerateMaterials(child, callback);\n }\n }\n\n /** Find all objects whose names match a pattern */\n public static filterObjects(object: Object3D, name: RegExp): Object3D[] {\n let result: Object3D[] = [];\n\n if (object.name && name.test(object.name)) {\n result.push(object);\n }\n\n for (const child of object.children) {\n result = result.concat(SceneTraversal.filterObjects(child, name));\n }\n\n return result;\n }\n\n /** Find all materials whose names match a pattern */\n public static filterMaterials(object: Object3D, name: RegExp): Material[] {\n let result: Material[] = [];\n\n if (object instanceof Mesh) {\n if (Array.isArray(object.material)) {\n for (const material of object.material) {\n if (material.name && name.test(material.name)) {\n result.push(material);\n }\n }\n } else {\n if (object.material.name && name.test(object.material.name)) {\n result.push(object.material);\n }\n }\n }\n\n for (const child of object.children) {\n result = result.concat(SceneTraversal.filterMaterials(child, name));\n }\n\n return result;\n }\n\n /** Set shadow properties on meshes */\n public static setShadowRecursive(\n object: Object3D,\n castShadow = true,\n receiveShadow = true,\n filter?: (object: Object3D) => boolean,\n ): void {\n if (object instanceof Mesh || \"isMesh\" in object) {\n (object as Mesh).castShadow = castShadow;\n (object as Mesh).receiveShadow = receiveShadow;\n }\n\n for (const child of object.children) {\n SceneTraversal.setShadowRecursive(\n child,\n castShadow,\n receiveShadow,\n filter,\n );\n }\n }\n}","import type { Material, Object3D } from \"three\";\nimport { InstancedMesh, Mesh } from \"three\";\nimport { GeometryHasher } from \"./GeometryHasher\";\nimport { SceneTraversal } from \"./SceneTraversal\";\n\nconst MIN_INSTANCE_COUNT = 2;\nconst DEFAULT_TOLERANCE = 1e-6;\n\n/** A group of meshes that can be instanced together */\ninterface MeshDescription {\n /** List of meshes */\n meshes: Mesh[];\n /** Materials to use */\n materials: Material[];\n /** Should cast shadows */\n castShadow: boolean;\n /** Should receive shadows */\n receiveShadow: boolean;\n}\n\n/** Configuration for instance assembly */\nexport interface InstanceAssemblerOptions {\n /** Filter which meshes to include */\n filter: (child: Mesh) => boolean;\n\n /** How close vertices need to be to count as identical */\n geometryTolerance: number;\n}\n\n/**\n * Combines identical meshes into instanced versions for better performance.\n * Meshes are considered identical if they share the same geometry and materials.\n */\nexport class InstanceAssembler {\n /**\n * Find meshes that can be instanced and combine them.\n * Only processes meshes that:\n * - Have no children\n * - Pass the filter function (if any)\n * - Share geometry with at least one other mesh\n *\n * @param container - Object containing meshes to process\n * @param options - Optional settings\n */\n public static assemble(\n container: Object3D,\n options: Partial<InstanceAssemblerOptions> = {},\n ): void {\n const dictionary = new Map<string, MeshDescription>();\n const instances: InstancedMesh[] = [];\n\n const tolerance = options.geometryTolerance ?? DEFAULT_TOLERANCE;\n const geometryHashes = new Map<string, string>();\n\n SceneTraversal.enumerateObjectsByType(container, Mesh, (child: Mesh) => {\n if (\n child.children.length === 0 &&\n (!options.filter || options.filter(child))\n ) {\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n\n let geometryHash = geometryHashes.get(child.geometry.uuid);\n if (!geometryHash) {\n geometryHash = GeometryHasher.getGeometryHash(\n child.geometry,\n tolerance,\n );\n geometryHashes.set(child.geometry.uuid, geometryHash);\n }\n\n const materialKey = materials.map((m) => m.uuid).join(\",\");\n const compositeKey = `${geometryHash}|${materialKey}`;\n\n const entry = dictionary.get(compositeKey) ?? {\n meshes: [],\n materials,\n castShadow: false,\n receiveShadow: false,\n };\n\n if (child.castShadow) {\n entry.castShadow = true;\n }\n\n if (child.receiveShadow) {\n entry.receiveShadow = true;\n }\n\n entry.meshes.push(child);\n dictionary.set(compositeKey, entry);\n }\n });\n\n for (const descriptor of dictionary.values()) {\n if (descriptor.meshes.length < MIN_INSTANCE_COUNT) {\n continue;\n }\n const { meshes, materials, castShadow, receiveShadow } = descriptor;\n\n const sortedMeshes = meshes.sort((a, b) => a.name.localeCompare(b.name));\n const defaultMesh = sortedMeshes[0];\n\n const instancedMesh = new InstancedMesh(\n defaultMesh.geometry,\n materials.length === 1 ? materials[0] : materials,\n sortedMeshes.length,\n );\n\n instancedMesh.name = defaultMesh.name;\n instancedMesh.castShadow = castShadow;\n instancedMesh.receiveShadow = receiveShadow;\n\n for (let i = 0; i < sortedMeshes.length; i++) {\n const mesh = sortedMeshes[i];\n mesh.updateWorldMatrix(true, false);\n instancedMesh.setMatrixAt(i, mesh.matrixWorld);\n instancedMesh.userData[mesh.uuid] = mesh.userData;\n }\n\n instancedMesh.instanceMatrix.needsUpdate = true;\n instances.push(instancedMesh);\n\n for (const mesh of sortedMeshes) {\n mesh.parent?.remove(mesh);\n }\n }\n\n if (instances.length > 0) {\n container.add(...instances);\n }\n }\n}\n","import type { Material, Object3D } from \"three\";\nimport { FrontSide, Mesh } from \"three\";\nimport { InstanceAssembler } from \"./InstanceAssembler\";\nimport { SceneTraversal } from \"./SceneTraversal\";\n\n/** Options for scene post-processing */\nexport interface SceneProcessorOptions {\n /** Clone the input asset before processing? */\n cloneAsset: boolean;\n\n /** Combine identical meshes into instances? */\n assembleInstances: boolean;\n\n /** Names matching these patterns will cast shadows */\n castShadowExpressions: RegExp[];\n\n /** Names matching these patterns will receive shadows */\n receiveShadwoExpressions: RegExp[];\n\n /** Names matching these patterns will be transparent */\n transparentMaterialExpressions: RegExp[];\n\n /** Names matching these patterns won't write to depth buffer */\n noDepthWriteMaterialExpressions: RegExp[];\n}\n\n/** Post-processes a scene based on name patterns */\nexport class SceneProcessor {\n /**\n * Process a scene to set up materials and shadows.\n * \n * @param asset - Scene to process\n * @param options - How to process the scene\n * @returns Processed scene root objects\n */\n public static process(\n asset: Object3D,\n options: Partial<SceneProcessorOptions>,\n ): Object3D[] {\n const container = options.cloneAsset !== false ? asset.clone() : asset;\n\n if (options.assembleInstances !== false) {\n InstanceAssembler.assemble(container);\n }\n\n SceneTraversal.enumerateMaterials(container, (material: Material) => {\n material.transparent = SceneProcessor.matchesAny(\n material.name,\n options.transparentMaterialExpressions,\n );\n material.depthWrite = !SceneProcessor.matchesAny(\n material.name,\n options.noDepthWriteMaterialExpressions,\n );\n material.side = FrontSide;\n material.forceSinglePass = true;\n material.depthTest = true;\n });\n\n SceneTraversal.enumerateObjectsByType(container, Mesh, (child: Mesh) => {\n child.castShadow = SceneProcessor.matchesAny(\n child.name,\n options.castShadowExpressions,\n );\n child.receiveShadow = SceneProcessor.matchesAny(\n child.name,\n options.receiveShadwoExpressions,\n );\n });\n\n return container.children;\n }\n\n /** Does the string match any of the patterns? */\n private static matchesAny(\n value: string,\n expressions: RegExp[] = [],\n ): boolean {\n return expressions.some((p) => p.test(value));\n }\n}","import type { AnimationClip, Object3D, SkinnedMesh } from \"three\";\nimport { AnimationMixer, BufferAttribute, Mesh, Vector3 } from \"three\";\n\n/** Number of components per vertex */\nconst COMPONENT_COUNT = 3;\n\n/** Convert skinned meshes to regular static meshes */\nexport class SkinnedMeshBaker {\n /**\n * Convert a skinned mesh to a regular mesh in its current pose.\n * The resulting mesh will have no bones but look identical.\n * \n * @param skinnedMesh - Mesh to convert\n * @returns Static mesh with baked vertex positions\n */\n public static bakePose(skinnedMesh: SkinnedMesh): Mesh {\n const bakedGeometry = skinnedMesh.geometry.clone();\n const position = bakedGeometry.attributes[\"position\"] as BufferAttribute;\n const newPositions = new Float32Array(position.count * COMPONENT_COUNT);\n const target = new Vector3();\n\n for (let i = 0; i < position.count; i++) {\n target.fromBufferAttribute(position, i);\n skinnedMesh.applyBoneTransform(i, target);\n newPositions[i * COMPONENT_COUNT + 0] = target.x;\n newPositions[i * COMPONENT_COUNT + 1] = target.y;\n newPositions[i * COMPONENT_COUNT + 2] = target.z;\n }\n\n bakedGeometry.setAttribute(\n \"position\",\n new BufferAttribute(newPositions, COMPONENT_COUNT),\n );\n bakedGeometry.computeVertexNormals();\n bakedGeometry.deleteAttribute(\"skinIndex\");\n bakedGeometry.deleteAttribute(\"skinWeight\");\n\n const mesh = new Mesh(bakedGeometry, skinnedMesh.material);\n mesh.name = skinnedMesh.name;\n return mesh;\n }\n\n /**\n * Bake a single frame from an animation into a static mesh.\n * \n * @param armature - Root object with bones (usually from GLTF)\n * @param skinnedMesh - Mesh to convert\n * @param timeOffset - Time in seconds within the animation\n * @param clip - Animation to get the pose from\n * @returns Static mesh with baked vertex positions\n */\n public static bakeAnimationFrame(\n armature: Object3D,\n skinnedMesh: SkinnedMesh,\n timeOffset: number,\n clip: AnimationClip,\n ): Mesh {\n const mixer = new AnimationMixer(armature);\n const action = mixer.clipAction(clip);\n action.play();\n mixer.setTime(timeOffset);\n\n armature.updateWorldMatrix(true, true);\n skinnedMesh.skeleton.update();\n\n return this.bakePose(skinnedMesh);\n }\n}","import type { Texture } from \"three\";\nimport { Box3, DirectionalLight, RGBAFormat, Spherical, Vector3 } from \"three\";\n\nconst RGBA_CHANNEL_COUNT = 4;\nconst RGB_CHANNEL_COUNT = 3;\n\nconst LUMINANCE_R = 0.2126;\nconst LUMINANCE_G = 0.7152;\nconst LUMINANCE_B = 0.0722;\n\n/** A directional light with spherical positioning controls */\nexport class Sun extends DirectionalLight {\n /** Internal vectors to avoid garbage collection */\n private readonly tempVector3D0 = new Vector3();\n private readonly tempVector3D1 = new Vector3();\n private readonly tempVector3D2 = new Vector3();\n private readonly tempVector3D3 = new Vector3();\n private readonly tempVector3D4 = new Vector3();\n private readonly tempVector3D5 = new Vector3();\n private readonly tempVector3D6 = new Vector3();\n private readonly tempVector3D7 = new Vector3();\n private readonly tempBox3 = new Box3();\n private readonly tempSpherical = new Spherical();\n\n /** Distance from the light to its target */\n public get distance(): number {\n return this.position.length();\n }\n\n /** Vertical angle from the ground in radians */\n public get elevation(): number {\n return this.tempSpherical.setFromVector3(this.position).phi;\n }\n\n /** Horizontal angle around the target in radians */\n public get azimuth(): number {\n return this.tempSpherical.setFromVector3(this.position).theta;\n }\n\n /** Set distance while keeping current angles */\n public set distance(value: number) {\n this.tempSpherical.setFromVector3(this.position);\n this.position.setFromSphericalCoords(\n value,\n this.tempSpherical.phi,\n this.tempSpherical.theta,\n );\n }\n\n /** Set elevation while keeping current distance and azimuth */\n public set elevation(value: number) {\n this.tempSpherical.setFromVector3(this.position);\n this.position.setFromSphericalCoords(\n this.tempSpherical.radius,\n value,\n this.tempSpherical.theta,\n );\n }\n\n /** Set azimuth while keeping current distance and elevation */\n public set azimuth(value: number) {\n this.tempSpherical.setFromVector3(this.position);\n this.position.setFromSphericalCoords(\n this.tempSpherical.radius,\n this.tempSpherical.phi,\n value,\n );\n }\n\n /** Configure shadows to cover all corners of a bounding box */\n public setShadowMapFromBox3(box3: Box3): void {\n const camera = this.shadow.camera;\n\n this.target.updateWorldMatrix(true, false);\n this.lookAt(this.target.getWorldPosition(this.tempVector3D0));\n\n this.updateWorldMatrix(true, false);\n\n const points: Vector3[] = [\n this.tempVector3D0.set(box3.min.x, box3.min.y, box3.min.z),\n this.tempVector3D1.set(box3.min.x, box3.min.y, box3.max.z),\n this.tempVector3D2.set(box3.min.x, box3.max.y, box3.min.z),\n this.tempVector3D3.set(box3.min.x, box3.max.y, box3.max.z),\n this.tempVector3D4.set(box3.max.x, box3.min.y, box3.min.z),\n this.tempVector3D5.set(box3.max.x, box3.min.y, box3.max.z),\n this.tempVector3D6.set(box3.max.x, box3.max.y, box3.min.z),\n this.tempVector3D7.set(box3.max.x, box3.max.y, box3.max.z),\n ];\n\n const inverseMatrix = this.matrixWorld.clone().invert();\n\n for (const point of points) {\n point.applyMatrix4(inverseMatrix);\n }\n\n const newBox3 = this.tempBox3.setFromPoints(points);\n\n camera.left = newBox3.min.x;\n camera.bottom = newBox3.min.y;\n camera.near = -newBox3.max.z;\n\n camera.right = newBox3.max.x;\n camera.top = newBox3.max.y;\n camera.far = -newBox3.min.z;\n\n camera.updateWorldMatrix(true, false);\n camera.updateProjectionMatrix();\n }\n\n /** Set light direction based on brightest point in an HDR texture */\n public setDirectionFromHDR(texture: Texture, distance = 1): void {\n const data = texture.image.data;\n const width = texture.image.width;\n const height = texture.image.height;\n\n let maxLuminance = 0;\n let maxIndex = 0;\n\n // Find brightest pixel\n\n const step =\n texture.format === RGBAFormat ? RGBA_CHANNEL_COUNT : RGB_CHANNEL_COUNT;\n for (let i = 0; i < data.length; i += step) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const luminance = LUMINANCE_R * r + LUMINANCE_G * g + LUMINANCE_B * b;\n if (luminance > maxLuminance) {\n maxLuminance = luminance;\n maxIndex = i;\n }\n }\n\n // Convert to spherical coordinates\n const pixelIndex = maxIndex / step;\n const x = pixelIndex % width;\n const y = Math.floor(pixelIndex / width);\n\n const u = x / width;\n const v = y / height;\n\n const elevation = v * Math.PI;\n const azimuth = u * -Math.PI * 2 - Math.PI / 2;\n\n this.position.setFromSphericalCoords(distance, elevation, azimuth);\n }\n}\n"],"names":["MAX_FOV","BiFovCamera","PerspectiveCamera","constructor","horizontalFov","verticalFov","aspect","near","far","super","this","horizontalFovInternal","verticalFovInternal","updateProjectionMatrix","value","MathUtils","clamp","setFov","horizontal","vertical","copyFovSettings","source","radians","degToRad","fov","radToDeg","Math","atan","tan","getEffectiveHorizontalFov","verticalRadians","getEffectiveVerticalFov","horizontalRadians","clone","camera","copy","Bounds","Box3","object","tempVector3A","Vector3","setFromObject","width","max","x","min","height","y","depth","z","diagonal","subVectors","length","getVolume","getSurfaceArea","w","h","d","GeometryHasher","getGeometryHash","geometry","tolerance","positionArray","attributes","array","positionHashParts","i","push","round","normalHashParts","normalArray","join","SceneTraversal","getObjectByName","name","child","children","result","getMaterialByName","Mesh","Array","isArray","material","enumerateObjectsByType","type","callback","enumerateMaterials","filterObjects","test","concat","filterMaterials","setShadowRecursive","castShadow","receiveShadow","filter","InstanceAssembler","assemble","container","options","dictionary","Map","instances","_a","geometryTolerance","geometryHashes","materials","geometryHash","get","uuid","set","compositeKey","map","m","entry","meshes","descriptor","values","sortedMeshes","sort","a","b","localeCompare","defaultMesh","instancedMesh","InstancedMesh","mesh","updateWorldMatrix","setMatrixAt","matrixWorld","userData","instanceMatrix","needsUpdate","_b","parent","remove","add","SceneProcessor","process","asset","cloneAsset","assembleInstances","transparent","matchesAny","transparentMaterialExpressions","depthWrite","noDepthWriteMaterialExpressions","side","FrontSide","forceSinglePass","depthTest","castShadowExpressions","receiveShadwoExpressions","expressions","some","p","SkinnedMeshBaker","bakePose","skinnedMesh","bakedGeometry","position","newPositions","Float32Array","count","target","fromBufferAttribute","applyBoneTransform","setAttribute","BufferAttribute","computeVertexNormals","deleteAttribute","bakeAnimationFrame","armature","timeOffset","clip","mixer","AnimationMixer","clipAction","play","setTime","skeleton","update","Sun","DirectionalLight","tempVector3D0","tempVector3D1","tempVector3D2","tempVector3D3","tempVector3D4","tempVector3D5","tempVector3D6","tempVector3D7","tempBox3","tempSpherical","Spherical","distance","elevation","setFromVector3","phi","azimuth","theta","setFromSphericalCoords","radius","setShadowMapFromBox3","box3","shadow","lookAt","getWorldPosition","points","inverseMatrix","invert","point","applyMatrix4","newBox3","setFromPoints","left","bottom","right","top","setDirectionFromHDR","texture","data","image","maxLuminance","maxIndex","step","format","RGBAFormat","luminance","pixelIndex","floor","PI"],"mappings":"0NAEA,MAOMA,EAAU,IAOV,MAAOC,UAAoBC,EAW/B,WAAAC,CACEC,EA1B2B,GA2B3BC,EA1ByB,GA2BzBC,EA1BmB,EA2BnBC,EA1BiB,EA2BjBC,EA1BgB,KA4BhBC,MAAMJ,EAAaC,EAAQC,EAAMC,GACjCE,KAAKC,sBAAwBP,EAC7BM,KAAKE,oBAAsBP,EAC3BK,KAAKG,yBAIP,iBAAWT,GACT,OAAOM,KAAKC,sBAId,eAAWN,GACT,OAAOK,KAAKE,oBAId,iBAAWR,CAAcU,GACvBJ,KAAKC,sBAAwBI,EAAUC,MAAMF,EA5CjC,EA4CiDd,GAC7DU,KAAKG,yBAIP,eAAWR,CAAYS,GACrBJ,KAAKE,oBAAsBG,EAAUC,MAAMF,EAlD/B,EAkD+Cd,GAC3DU,KAAKG,yBAQA,MAAAI,CAAOC,EAAoBC,GAChCT,KAAKC,sBAAwBI,EAAUC,MAAME,EA5DjC,EA4DsDlB,GAClEU,KAAKE,oBAAsBG,EAAUC,MAAMG,EA7D/B,EA6DkDnB,GAC9DU,KAAKG,yBAOA,eAAAO,CAAgBC,GACrBX,KAAKC,sBAAwBU,EAAOjB,cACpCM,KAAKE,oBAAsBS,EAAOhB,YAClCK,KAAKG,yBAQS,sBAAAA,GACd,GAAIH,KAAKJ,QAAU,EAAG,CAEpB,MAAMgB,EAAUP,EAAUQ,SAASb,KAAKC,uBACxCD,KAAKc,IAAMT,EAAUU,SAC8B,EAAjDC,KAAKC,KAAKD,KAAKE,IAAIN,EAAU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,uBAAuBN,EAR3BxK,KAAK2M,MAAMD,EAAa1L,GAGpBI,EAEQpB,KAAK4M,GAHjB1L,EAAIF,GAIOhB,KAAK4M,GAAK,EAAI5M,KAAK4M,GAAK"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-zoo",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "zoo of tiny three js tools",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rm -rf dist",
|
|
7
|
-
"build": "npm run clean && rollup -c"
|
|
7
|
+
"build": "npm run clean && rollup -c",
|
|
8
|
+
"build:prod": "npm run clean && NODE_ENV=production rollup -c",
|
|
9
|
+
"prepublishOnly": "npm run build:prod"
|
|
8
10
|
},
|
|
9
11
|
"main": "dist/index.js",
|
|
12
|
+
"module": "dist/index.js",
|
|
10
13
|
"types": "dist/index.d.ts",
|
|
11
14
|
"exports": {
|
|
12
15
|
".": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": {
|
|
18
|
+
"development": "./dist/index.js",
|
|
19
|
+
"production": "./dist/index.min.js",
|
|
20
|
+
"default": "./dist/index.min.js"
|
|
21
|
+
}
|
|
15
22
|
}
|
|
16
23
|
},
|
|
17
24
|
"files": [
|
|
@@ -30,6 +37,7 @@
|
|
|
30
37
|
},
|
|
31
38
|
"devDependencies": {
|
|
32
39
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
40
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
33
41
|
"@types/three": "^0.176.0",
|
|
34
42
|
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
|
35
43
|
"@typescript-eslint/parser": "^8.32.0",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { PerspectiveCamera } from "three";
|
|
2
|
-
export declare class DoubleFOVCamera extends PerspectiveCamera {
|
|
3
|
-
horizontalFov: number;
|
|
4
|
-
verticalFov: number;
|
|
5
|
-
constructor(horizontalFov?: number, verticalFov?: number, aspect?: number, near?: number, far?: number);
|
|
6
|
-
updateProjectionMatrix(): void;
|
|
7
|
-
}
|
package/dist/Enumerator.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Material, Object3D } from "three";
|
|
2
|
-
type Constructor<T> = abstract new (...args: never[]) => T;
|
|
3
|
-
export declare class Enumerator {
|
|
4
|
-
static getObjectByName(object: Object3D, name: string): Object3D | null;
|
|
5
|
-
static getMaterialByName(object: Object3D, name: string): Material | null;
|
|
6
|
-
static enumerateObjectsByType<T>(object: Object3D, type: Constructor<T>, callback: (instance: T) => void): void;
|
|
7
|
-
static enumerateMaterials(object: Object3D, callback: (material: Material) => void): void;
|
|
8
|
-
static filterObjects(object: Object3D, name: RegExp): Object3D[];
|
|
9
|
-
static filterMaterials(object: Object3D, name: RegExp): Material[];
|
|
10
|
-
static setShadowRecursive(object: Object3D, castShadow?: boolean, receiveShadow?: boolean): void;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { BufferGeometry } from "three";
|
|
2
|
-
/**
|
|
3
|
-
* Utility class for comparing and hashing BufferGeometry instances with tolerance support.
|
|
4
|
-
*/
|
|
5
|
-
export declare class GeometryComparator {
|
|
6
|
-
/**
|
|
7
|
-
* Generates a consistent hash for a BufferGeometry based on its contents and tolerance.
|
|
8
|
-
*
|
|
9
|
-
* @param geometry - The geometry to hash
|
|
10
|
-
* @param tolerance - Precision level for number comparison (values within tolerance are considered equal)
|
|
11
|
-
* @returns A string hash that will be identical for geometrically equivalent geometries
|
|
12
|
-
*/
|
|
13
|
-
static getGeometryHash(geometry: BufferGeometry, tolerance?: number): string;
|
|
14
|
-
/**
|
|
15
|
-
* Compares two BufferGeometry instances for approximate equality.
|
|
16
|
-
* Early exit if UUIDs match (same object or cloned geometry).
|
|
17
|
-
*/
|
|
18
|
-
static compare(firstGeometry: BufferGeometry, secondGeometry: BufferGeometry, tolerance?: number): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Generates a hash for a buffer attribute with tolerance.
|
|
21
|
-
*/
|
|
22
|
-
private static getAttributeHash;
|
|
23
|
-
/**
|
|
24
|
-
* Compares two buffer attributes with tolerance.
|
|
25
|
-
*/
|
|
26
|
-
private static compareBufferAttributes;
|
|
27
|
-
}
|