@atom.io/spa 0.0.9 → 0.0.10
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 +30 -10
- package/README.mdx +16 -5
- package/dist/BrandMarkScene-CBYk-RJ2.js +140 -0
- package/dist/BrandMarkScene-CBYk-RJ2.js.map +1 -0
- package/dist/astro-client.js +1 -1
- package/dist/astro-server.js +1 -1
- package/dist/brand-css.d.ts +2 -0
- package/dist/brand-model.d.ts +32 -0
- package/dist/brand-model.d.ts.map +1 -0
- package/dist/brand-model.js +120 -0
- package/dist/brand-model.js.map +1 -0
- package/dist/brand.css +37 -0
- package/dist/brand.d.ts +13 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +94 -0
- package/dist/brand.js.map +1 -0
- package/dist/client.min.js +1 -1
- package/dist/development/BrandMarkScene-BDdC7K5M.js +140 -0
- package/dist/development/BrandMarkScene-BDdC7K5M.js.map +1 -0
- package/dist/development/astro-client.js +1 -1
- package/dist/development/astro-server.js +1 -1
- package/dist/development/brand-model.js +120 -0
- package/dist/development/brand-model.js.map +1 -0
- package/dist/development/brand.css +37 -0
- package/dist/development/brand.js +94 -0
- package/dist/development/brand.js.map +1 -0
- package/dist/development/{dom-BRFv7FP_.js → dom-CEVtlaav.js} +4 -3
- package/dist/development/dom-CEVtlaav.js.map +1 -0
- package/dist/development/floating.js.map +1 -1
- package/dist/development/hot.js +2 -2
- package/dist/development/hot.js.map +1 -1
- package/dist/development/{identity-DwB8MTM1.js → identity-B8wTFkyW.js} +2 -2
- package/dist/development/{identity-DwB8MTM1.js.map → identity-B8wTFkyW.js.map} +1 -1
- package/dist/development/index.js +1 -1
- package/dist/development/konva.js +1 -1
- package/dist/development/motion.js +38 -19
- package/dist/development/motion.js.map +1 -1
- package/dist/development/renderer.js +1 -1
- package/dist/development/{server-renderer-u1-c5PGd.js → server-renderer-zAqEL1g1.js} +2 -2
- package/dist/development/{server-renderer-u1-c5PGd.js.map → server-renderer-zAqEL1g1.js.map} +1 -1
- package/dist/development/server.js +1 -1
- package/dist/development/three-CsZ6Od1C.js +527 -0
- package/dist/development/three-CsZ6Od1C.js.map +1 -0
- package/dist/development/three.js +1 -509
- package/dist/{dom--HZvmgqd.js → dom-DUpa3Sj2.js} +4 -3
- package/dist/dom-DUpa3Sj2.js.map +1 -0
- package/dist/floating.js.map +1 -1
- package/dist/hot.d.ts.map +1 -1
- package/dist/hot.js.map +1 -1
- package/dist/{identity-oFU5p-Qj.js → identity-ByJswZtF.js} +2 -2
- package/dist/{identity-oFU5p-Qj.js.map → identity-ByJswZtF.js.map} +1 -1
- package/dist/index-DdA39aMv.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/konva.js +1 -1
- package/dist/motion.d.ts +2 -0
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +38 -19
- package/dist/motion.js.map +1 -1
- package/dist/renderer.js +1 -1
- package/dist/{server-renderer-BYFDmqnM.js → server-renderer-D7CdyOMo.js} +2 -2
- package/dist/{server-renderer-BYFDmqnM.js.map → server-renderer-D7CdyOMo.js.map} +1 -1
- package/dist/server.js +1 -1
- package/dist/size.json +12 -12
- package/dist/three-DcYxRXPW.js +527 -0
- package/dist/three-DcYxRXPW.js.map +1 -0
- package/dist/three.d.ts +21 -0
- package/dist/three.d.ts.map +1 -1
- package/dist/three.js +1 -509
- package/package.json +39 -19
- package/src/BrandMark.module.css +25 -0
- package/src/BrandMark.tsx +106 -0
- package/src/BrandMarkScene.module.css +10 -0
- package/src/BrandMarkScene.tsx +116 -0
- package/src/brand-css.d.ts +2 -0
- package/src/brand-model.ts +177 -0
- package/src/brand.ts +3 -0
- package/src/dom.ts +8 -1
- package/src/hot.ts +3 -2
- package/src/lasertag.d.ts +1 -0
- package/src/motion-layout.ts +55 -26
- package/src/motion.ts +3 -0
- package/src/three.ts +69 -22
- package/dist/development/dom-BRFv7FP_.js.map +0 -1
- package/dist/development/three.js.map +0 -1
- package/dist/dom--HZvmgqd.js.map +0 -1
- package/dist/three.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"three-DcYxRXPW.js","names":[],"sources":["../src/three-events.ts","../src/three.ts"],"sourcesContent":["import * as THREE from \"three\"\n\nexport interface ThreePointerEvent<N extends THREE.Object3D = THREE.Object3D> {\n\ttype: string\n\tnativeEvent: PointerEvent\n\ttarget: THREE.Object3D\n\tcurrentTarget: N\n\tintersection: THREE.Intersection\n\tray: THREE.Ray\n\tpointerId: number\n\tbutton: number\n\tbuttons: number\n\tclientX: number\n\tclientY: number\n\tstopPropagation(): void\n\tpreventDefault(): void\n\tsetPointerCapture(): void\n\treleasePointerCapture(): void\n\thasPointerCapture(): boolean\n}\nexport type ThreeEventHandler<N extends THREE.Object3D = THREE.Object3D> = (\n\tevent: ThreePointerEvent<N>,\n) => void\nexport interface ThreeEventAttributes<\n\tN extends THREE.Object3D = THREE.Object3D,\n> {\n\tonPointerDown?: ThreeEventHandler<N>\n\tonPointerUp?: ThreeEventHandler<N>\n\tonPointerMove?: ThreeEventHandler<N>\n\tonPointerEnter?: ThreeEventHandler<N>\n\tonPointerLeave?: ThreeEventHandler<N>\n\tonPointerOver?: ThreeEventHandler<N>\n\tonPointerOut?: ThreeEventHandler<N>\n\tonPointerCancel?: ThreeEventHandler<N>\n\tonClick?: ThreeEventHandler<N>\n}\ntype Hit = { node: THREE.Object3D; intersection: THREE.Intersection }\ntype Handler = ThreeEventHandler\nconst suspended = new WeakSet<THREE.Object3D>()\nexport function suspendThree(node: THREE.Object3D): () => void {\n\tsuspended.add(node)\n\tfor (const manager of managers) manager.remove(node)\n\treturn () => {\n\t\tsuspended.delete(node)\n\t}\n}\nconst listeners = new WeakMap<THREE.Object3D, Map<string, Set<Handler>>>()\nconst managers = new Set<{ remove(node: THREE.Object3D): void }>()\n\nexport function listenThree(\n\tnode: THREE.Object3D,\n\ttype: string,\n\thandler: Handler,\n): () => void {\n\tconst events = listeners.get(node) ?? new Map<string, Set<Handler>>()\n\tlisteners.set(node, events)\n\tconst handlers = events.get(type) ?? new Set<Handler>()\n\tevents.set(type, handlers)\n\thandlers.add(handler)\n\treturn () => {\n\t\thandlers.delete(handler)\n\t\tif (!handlers.size) events.delete(type)\n\t}\n}\nexport function forgetThree(node: THREE.Object3D): void {\n\tconst errors: unknown[] = []\n\tfor (const manager of managers) {\n\t\ttry {\n\t\t\tmanager.remove(node)\n\t\t} catch (error) {\n\t\t\terrors.push(error)\n\t\t}\n\t}\n\tlisteners.delete(node)\n\tif (errors.length) throw new AggregateError(errors)\n}\n\nexport interface ThreeEventManager {\n\tupdate(): void\n\t/** Release hover, press, and capture state for a removed subtree. */\n\tremove(node: THREE.Object3D): void\n\tdispose(): void\n}\n\n/** Attach raycast pointer routing to a canvas; usable with borrowed scene roots. */\nexport function createThreeEvents(\n\tcanvas: HTMLCanvasElement,\n\tscene: THREE.Object3D,\n\tcamera: () => THREE.Camera,\n\tonError: (error: unknown) => void = (error) => {\n\t\tthrow error\n\t},\n): ThreeEventManager {\n\tconst raycaster = new THREE.Raycaster()\n\tconst pointer = new THREE.Vector2()\n\tconst hovering = new Map<number, Hit>()\n\tconst pressed = new Map<number, Hit>()\n\tconst captures = new Map<number, Hit>()\n\tconst last = new Map<number, PointerEvent>()\n\tlet dead = false\n\tconst path = (node: THREE.Object3D) => {\n\t\tconst nodes: THREE.Object3D[] = []\n\t\tfor (let at: THREE.Object3D | null = node; at; at = at.parent) {\n\t\t\tnodes.push(at)\n\t\t\tif (at === scene) return nodes\n\t\t}\n\t\treturn []\n\t}\n\tconst contains = (node: THREE.Object3D, child: THREE.Object3D) => {\n\t\tfor (let at: THREE.Object3D | null = child; at; at = at.parent)\n\t\t\tif (at === node) return true\n\t\treturn false\n\t}\n\tconst eligible = (intersection: THREE.Intersection) => {\n\t\tconst nodes = path(intersection.object)\n\t\tif (\n\t\t\t!nodes.length ||\n\t\t\tnodes.some((node) => !node.visible || suspended.has(node))\n\t\t)\n\t\t\treturn false\n\t\tconst material = (intersection.object as THREE.Mesh).material\n\t\treturn (\n\t\t\t!material ||\n\t\t\t(Array.isArray(material)\n\t\t\t\t? material[intersection.face?.materialIndex ?? 0]?.visible !== false\n\t\t\t\t: material.visible)\n\t\t)\n\t}\n\tconst pick = (event: PointerEvent): Hit | undefined => {\n\t\tconst bounds = canvas.getBoundingClientRect()\n\t\tif (!bounds.width || !bounds.height) return undefined\n\t\tconst active = camera()\n\t\tscene.updateWorldMatrix(true, true)\n\t\tactive.updateWorldMatrix(true, false)\n\t\tpointer.set(\n\t\t\t((event.clientX - bounds.left) / bounds.width) * 2 - 1,\n\t\t\t1 - ((event.clientY - bounds.top) / bounds.height) * 2,\n\t\t)\n\t\traycaster.layers.mask = active.layers.mask\n\t\traycaster.setFromCamera(pointer, active)\n\t\tif (\n\t\t\tevent.clientX < bounds.left ||\n\t\t\tevent.clientX > bounds.right ||\n\t\t\tevent.clientY < bounds.top ||\n\t\t\tevent.clientY > bounds.bottom\n\t\t)\n\t\t\treturn undefined\n\t\tconst intersection = raycaster.intersectObject(scene, true).find(eligible)\n\t\treturn intersection ? { node: intersection.object, intersection } : undefined\n\t}\n\tconst nativeCapture = (id: number) => {\n\t\tif (canvas.hasPointerCapture?.(id)) canvas.releasePointerCapture(id)\n\t}\n\tconst dispatch = (\n\t\ttype: string,\n\t\thit: Hit,\n\t\tnativeEvent: PointerEvent,\n\t\tnodes = path(hit.node),\n\t) => {\n\t\tlet stopped = false\n\t\tfor (const node of nodes) {\n\t\t\tif (dead) break\n\t\t\tconst event: ThreePointerEvent = {\n\t\t\t\ttype,\n\t\t\t\tnativeEvent,\n\t\t\t\ttarget: hit.node,\n\t\t\t\tcurrentTarget: node,\n\t\t\t\tintersection: hit.intersection,\n\t\t\t\tray: raycaster.ray.clone(),\n\t\t\t\tpointerId: nativeEvent.pointerId,\n\t\t\t\tbutton: nativeEvent.button,\n\t\t\t\tbuttons: nativeEvent.buttons,\n\t\t\t\tclientX: nativeEvent.clientX,\n\t\t\t\tclientY: nativeEvent.clientY,\n\t\t\t\tstopPropagation() {\n\t\t\t\t\tstopped = true\n\t\t\t\t},\n\t\t\t\tpreventDefault() {\n\t\t\t\t\tnativeEvent.preventDefault()\n\t\t\t\t},\n\t\t\t\tsetPointerCapture() {\n\t\t\t\t\tcanvas.setPointerCapture(nativeEvent.pointerId)\n\t\t\t\t\tcaptures.set(nativeEvent.pointerId, {\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tintersection: hit.intersection,\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\treleasePointerCapture() {\n\t\t\t\t\tif (captures.get(nativeEvent.pointerId)?.node === node) {\n\t\t\t\t\t\tcaptures.delete(nativeEvent.pointerId)\n\t\t\t\t\t\tnativeCapture(nativeEvent.pointerId)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thasPointerCapture() {\n\t\t\t\t\treturn captures.get(nativeEvent.pointerId)?.node === node\n\t\t\t\t},\n\t\t\t}\n\t\t\tfor (const handler of [...(listeners.get(node)?.get(type) ?? [])])\n\t\t\t\tif (!dead && listeners.get(node)?.get(type)?.has(handler)) handler(event)\n\t\t\tif (stopped) break\n\t\t}\n\t}\n\tconst hover = (event: PointerEvent, next?: Hit) => {\n\t\tconst previous = hovering.get(event.pointerId)\n\t\tif (previous?.node === next?.node) {\n\t\t\tif (next) hovering.set(event.pointerId, next)\n\t\t\treturn\n\t\t}\n\t\tconst oldPath = previous ? path(previous.node) : []\n\t\tconst newPath = next ? path(next.node) : []\n\t\t// Publish state first so handlers may remove nodes or dispose this manager safely.\n\t\tif (next) hovering.set(event.pointerId, next)\n\t\telse hovering.delete(event.pointerId)\n\t\tif (previous) {\n\t\t\tdispatch(`pointerout`, previous, event)\n\t\t\tfor (const node of oldPath)\n\t\t\t\tif (!newPath.includes(node))\n\t\t\t\t\tdispatch(`pointerleave`, previous, event, [node])\n\t\t}\n\t\tif (next && path(next.node).length) {\n\t\t\tdispatch(`pointerover`, next, event)\n\t\t\tfor (const node of newPath.reverse())\n\t\t\t\tif (!oldPath.includes(node))\n\t\t\t\t\tdispatch(`pointerenter`, next, event, [node])\n\t\t}\n\t}\n\tconst cancel = (event: PointerEvent) => {\n\t\tconst hit = captures.get(event.pointerId) ?? pressed.get(event.pointerId)\n\t\tcaptures.delete(event.pointerId)\n\t\tpressed.delete(event.pointerId)\n\t\ttry {\n\t\t\tif (hit) dispatch(`pointercancel`, hit, event)\n\t\t} finally {\n\t\t\tnativeCapture(event.pointerId)\n\t\t}\n\t}\n\tconst handle = (event: PointerEvent) => {\n\t\ttry {\n\t\t\tif (event.type === `lostpointercapture`) {\n\t\t\t\tcancel(event)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (event.type === `pointercancel`) {\n\t\t\t\tcancel(event)\n\t\t\t\thover(event)\n\t\t\t\tlast.delete(event.pointerId)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (event.type === `pointerleave`) {\n\t\t\t\tlast.set(event.pointerId, event)\n\t\t\t\thover(event)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlast.set(event.pointerId, event)\n\t\t\tconst hit = pick(event)\n\t\t\thover(event, hit)\n\t\t\tif (dead) return\n\t\t\tconst capture = captures.get(event.pointerId)\n\t\t\tif (capture && hit && contains(capture.node, hit.node))\n\t\t\t\tcapture.intersection = hit.intersection\n\t\t\tconst delivery = capture ?? hit\n\t\t\tif (event.type === `pointerdown`) {\n\t\t\t\tif (hit) {\n\t\t\t\t\tpressed.set(event.pointerId, hit)\n\t\t\t\t\tcanvas.setPointerCapture?.(event.pointerId)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (event.type === `pointerup`) {\n\t\t\t\tconst down = pressed.get(event.pointerId)\n\t\t\t\tpressed.delete(event.pointerId)\n\t\t\t\ttry {\n\t\t\t\t\t// Capture may belong to an ancestor of the original hit.\n\t\t\t\t\tif (down && !capture && down.node !== hit?.node)\n\t\t\t\t\t\tdispatch(`pointercancel`, down, event)\n\t\t\t\t\tif (delivery) dispatch(`pointerup`, delivery, event)\n\t\t\t\t\tif (down && down.node === hit?.node && event.button === 0)\n\t\t\t\t\t\tdispatch(`click`, hit, event)\n\t\t\t\t} finally {\n\t\t\t\t\tcaptures.delete(event.pointerId)\n\t\t\t\t\tnativeCapture(event.pointerId)\n\t\t\t\t\tif (event.pointerType === `touch`) {\n\t\t\t\t\t\thover(event)\n\t\t\t\t\t\tlast.delete(event.pointerId)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (delivery) dispatch(event.type, delivery, event)\n\t\t} catch (error) {\n\t\t\tonError(error)\n\t\t}\n\t}\n\tconst events = [\n\t\t`pointerdown`,\n\t\t`pointerup`,\n\t\t`pointermove`,\n\t\t`pointerleave`,\n\t\t`pointercancel`,\n\t\t`lostpointercapture`,\n\t] as const\n\tfor (const type of events) canvas.addEventListener(type, handle)\n\tconst manager = {\n\t\t/** Re-pick stationary pointers after camera, geometry, or transforms change. */\n\t\tupdate() {\n\t\t\tif (dead) return\n\t\t\ttry {\n\t\t\t\tfor (const event of last.values())\n\t\t\t\t\tif (event.type !== `pointerleave`) hover(event, pick(event))\n\t\t\t} catch (error) {\n\t\t\t\tonError(error)\n\t\t\t}\n\t\t},\n\t\tremove(node: THREE.Object3D) {\n\t\t\tconst errors: unknown[] = []\n\t\t\tfor (const [id, hit] of hovering)\n\t\t\t\tif (contains(node, hit.node)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\thover(last.get(id)!)\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tfor (const [id, hit] of [...pressed, ...captures])\n\t\t\t\tif (contains(node, hit.node)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcancel(last.get(id)!)\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tif (errors.length) throw new AggregateError(errors)\n\t\t},\n\t\tdispose() {\n\t\t\tif (dead) return\n\t\t\tdead = true\n\t\t\tfor (const type of events) canvas.removeEventListener(type, handle)\n\t\t\tfor (const id of new Set([...pressed.keys(), ...captures.keys()]))\n\t\t\t\tnativeCapture(id)\n\t\t\thovering.clear()\n\t\t\tpressed.clear()\n\t\t\tcaptures.clear()\n\t\t\tlast.clear()\n\t\t\tmanagers.delete(manager)\n\t\t},\n\t}\n\tmanagers.add(manager)\n\treturn manager\n}\n","import { isPresent, owner, reportScopeError, within } from \"./core.ts\"\nimport type { ThreeEventAttributes, ThreeEventHandler } from \"./three-events.ts\"\nimport {\n\tcreateThreeEvents,\n\tforgetThree,\n\tlistenThree,\n\tsuspendThree,\n} from \"./three-events.ts\"\n\nexport type {\n\tThreeEventAttributes,\n\tThreeEventHandler,\n\tThreeEventManager,\n\tThreePointerEvent,\n} from \"./three-events.ts\"\nexport { createThreeEvents } from \"./three-events.ts\"\nimport * as THREE from \"three\"\n\nimport type { Children, SpaElement } from \"./index.ts\"\nimport { onCleanup, onMount } from \"./index.ts\"\nimport type { CapabilityAttributes } from \"./jsx-runtime.ts\"\nimport { jsx } from \"./jsx-runtime.ts\"\nimport {\n\tbindScene,\n\tcreateSceneRenderer,\n\tonSceneFrame,\n\tsceneComponent,\n} from \"./renderer.ts\"\n\ntype Resource = THREE.Object3D | THREE.BufferGeometry | THREE.Material\ntype Vector3 = readonly [number, number, number]\nexport interface ObjectProps<N extends THREE.Object3D = THREE.Object3D>\n\textends CapabilityAttributes<`three`>, ThreeEventAttributes<N> {\n\tchildren?: Children\n\tposition?: Vector3\n\trotation?: Vector3\n\tscale?: Vector3 | number\n\tvisible?: boolean\n\tname?: string\n\tref?: (object: N | null) => void\n}\nconst constructors = {\n\tGroup: THREE.Group,\n\tMesh: THREE.Mesh,\n\tLineSegments: THREE.LineSegments,\n\tBufferGeometry: THREE.BufferGeometry,\n\tLineBasicMaterial: THREE.LineBasicMaterial,\n\tPerspectiveCamera: THREE.PerspectiveCamera,\n\tAmbientLight: THREE.AmbientLight,\n\tPointLight: THREE.PointLight,\n\tDirectionalLight: THREE.DirectionalLight,\n\tBoxGeometry: THREE.BoxGeometry,\n\tSphereGeometry: THREE.SphereGeometry,\n\tPlaneGeometry: THREE.PlaneGeometry,\n\tMeshStandardMaterial: THREE.MeshStandardMaterial,\n\tMeshBasicMaterial: THREE.MeshBasicMaterial,\n\tMeshNormalMaterial: THREE.MeshNormalMaterial,\n}\nconst drawableDefaults = new WeakMap<\n\tTHREE.Mesh | THREE.LineSegments,\n\t{\n\t\tgeometry: THREE.BufferGeometry\n\t\tmaterial: THREE.Material | THREE.Material[]\n\t\townsGeometry: boolean\n\t\townsMaterial: boolean\n\t}\n>()\nconst borrowedDrawableDefaults = new WeakMap<\n\tTHREE.Mesh | THREE.LineSegments,\n\t{\n\t\tgeometry: THREE.BufferGeometry\n\t\tmaterial: THREE.Material | THREE.Material[]\n\t}\n>()\nconst constructorArgs = new WeakMap<Resource, unknown[]>()\nconst eventHandlers = new WeakMap<Resource, Map<string, () => void>>()\nconst defaults = new WeakMap<Resource, Map<string, any>>()\nfunction writeProperty(node: Resource, key: string, value: any): void {\n\tconst target = node as any\n\tif (!(key in target)) throw new Error(`spa/three: unknown property ${key}`)\n\tconst current = target[key]\n\tif (current?.isColor) current.set(value)\n\telse if (Array.isArray(value) && typeof current?.set === `function`)\n\t\tcurrent.set(...value)\n\telse if (key === `scale` && typeof value === `number`) current.setScalar(value)\n\telse if (current?.copy && value?.constructor === current.constructor)\n\t\tcurrent.copy(value)\n\telse target[key] = value\n\tif (node instanceof THREE.PerspectiveCamera) node.updateProjectionMatrix()\n}\nconst renderer = createSceneRenderer<Resource>({\n\ttarget(node) {\n\t\treturn {\n\t\t\tkind: `three`,\n\t\t\tnode,\n\t\t\t...(node instanceof THREE.Object3D\n\t\t\t\t? {\n\t\t\t\t\t\tsuspend: () => suspendThree(node),\n\t\t\t\t\t\tlisten: (type: string, listener: () => void) =>\n\t\t\t\t\t\t\tlistenThree(node, type, listener),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\tread(key) {\n\t\t\t\tconst value = (node as any)[key]\n\t\t\t\treturn value?.isColor\n\t\t\t\t\t? value.getStyle()\n\t\t\t\t\t: value?.isVector3 || value?.isEuler\n\t\t\t\t\t\t? [value.x, value.y, value.z]\n\t\t\t\t\t\t: value\n\t\t\t},\n\t\t\twrite(key, value) {\n\t\t\t\twriteProperty(node, key, value)\n\t\t\t},\n\t\t}\n\t},\n\tcreate(type, props) {\n\t\tconst Constructor = constructors[type as keyof typeof constructors]\n\t\tif (!Constructor) throw new Error(`spa/three: unknown node ${type}`)\n\t\tconst node = new (Constructor as any)(...(props[`args`] ?? [])) as Resource\n\t\t// Drawables' implicit resources are replaced by owned JSX resources below.\n\t\tif (node instanceof THREE.Mesh || node instanceof THREE.LineSegments)\n\t\t\tdrawableDefaults.set(node, {\n\t\t\t\tgeometry: node.geometry,\n\t\t\t\tmaterial: node.material,\n\t\t\t\townsGeometry: props[`args`]?.[0] === undefined,\n\t\t\t\townsMaterial: props[`args`]?.[1] === undefined,\n\t\t\t})\n\t\tconstructorArgs.set(node, [...(props[`args`] ?? [])])\n\t\tdefaults.set(node, new Map())\n\t\teventHandlers.set(node, new Map())\n\t\treturn node\n\t},\n\tupdate(node, props, previous) {\n\t\tif (!equalArgs(constructorArgs.get(node)!, props[`args`]))\n\t\t\tthrow new Error(\n\t\t\t\t`spa/three: change the component key to replace constructor args`,\n\t\t\t)\n\t\tconst target = node as any\n\t\tconst saved = defaults.get(node)!\n\t\tfor (const key of new Set([\n\t\t\t...Object.keys(previous),\n\t\t\t...Object.keys(props),\n\t\t])) {\n\t\t\tif (\n\t\t\t\t/^(key|children|ref|args)$/.test(key) ||\n\t\t\t\tObject.is(props[key], previous[key])\n\t\t\t)\n\t\t\t\tcontinue\n\t\t\tif (key.startsWith(`on`)) {\n\t\t\t\tif (\n\t\t\t\t\t!(node instanceof THREE.Object3D) ||\n\t\t\t\t\t!/^on(Pointer(Down|Up|Move|Enter|Leave|Over|Out|Cancel)|Click)$/.test(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(`spa/three: unknown event ${key}`)\n\t\t\t\tconst handlers = eventHandlers.get(node)!\n\t\t\t\thandlers.get(key)?.()\n\t\t\t\thandlers.delete(key)\n\t\t\t\tconst handler = props[key] as ThreeEventHandler | undefined\n\t\t\t\tif (handler) {\n\t\t\t\t\tconst scope = owner!\n\t\t\t\t\thandlers.set(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tlistenThree(node, key.slice(2).toLowerCase(), (event) => {\n\t\t\t\t\t\t\twithin(scope, () => {\n\t\t\t\t\t\t\t\thandler(event)\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!(key in target)) throw new Error(`spa/three: unknown property ${key}`)\n\t\t\tconst current = target[key]\n\t\t\tif (!saved.has(key))\n\t\t\t\tsaved.set(key, current?.clone ? current.clone() : current)\n\t\t\tconst value = props[key] === undefined ? saved.get(key) : props[key]\n\t\t\twriteProperty(node, key, value)\n\t\t}\n\t\tif (node instanceof THREE.PerspectiveCamera) node.updateProjectionMatrix()\n\t},\n\tchildren(parent, children, activeChildren) {\n\t\tif (!(parent instanceof THREE.Object3D)) {\n\t\t\tif (children.length)\n\t\t\t\tthrow new Error(`spa/three: resources cannot contain children`)\n\t\t\treturn\n\t\t}\n\t\tconst objects = children.filter(\n\t\t\t(child): child is THREE.Object3D => child instanceof THREE.Object3D,\n\t\t)\n\t\tif (\n\t\t\tparent.children.length !== objects.length ||\n\t\t\tobjects.some((child, index) => child !== parent.children[index])\n\t\t) {\n\t\t\tconst wanted = new Set(objects)\n\t\t\tfor (const child of [...parent.children])\n\t\t\t\tif (!wanted.has(child)) parent.remove(child)\n\t\t\tfor (const child of objects) if (child.parent !== parent) parent.add(child)\n\t\t\tparent.children.splice(0, parent.children.length, ...objects)\n\t\t}\n\t\tconst resources = children.filter(\n\t\t\t(child) => !(child instanceof THREE.Object3D),\n\t\t)\n\t\tif (\n\t\t\tresources.length &&\n\t\t\t!(parent instanceof THREE.Mesh || parent instanceof THREE.LineSegments)\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t`spa/three: geometry and material require a Mesh or LineSegments parent`,\n\t\t\t)\n\t\tif (parent instanceof THREE.Mesh || parent instanceof THREE.LineSegments) {\n\t\t\tconst geometries = resources.filter(\n\t\t\t\t(child) => child instanceof THREE.BufferGeometry,\n\t\t\t)\n\t\t\tconst materials = resources.filter(\n\t\t\t\t(child) => child instanceof THREE.Material,\n\t\t\t)\n\t\t\tconst activeGeometries = activeChildren.filter(\n\t\t\t\t(child) => child instanceof THREE.BufferGeometry,\n\t\t\t)\n\t\t\tconst activeMaterials = activeChildren.filter(\n\t\t\t\t(child) => child instanceof THREE.Material,\n\t\t\t)\n\t\t\tif (activeGeometries.length > 1 || activeMaterials.length > 1)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`spa/three: each ${parent instanceof THREE.Mesh ? `Mesh` : `LineSegments`} accepts one geometry and one material`,\n\t\t\t\t)\n\t\t\tconst owned = drawableDefaults.get(parent)\n\t\t\tlet baseline = owned ?? borrowedDrawableDefaults.get(parent)\n\t\t\tif (!baseline) {\n\t\t\t\tbaseline = { geometry: parent.geometry, material: parent.material }\n\t\t\t\tborrowedDrawableDefaults.set(parent, baseline)\n\t\t\t}\n\t\t\t// Retention owns outgoing resources without occupying incoming attachment slots.\n\t\t\tparent.geometry =\n\t\t\t\tactiveGeometries[0] ??\n\t\t\t\tgeometries.find((geometry) => geometry === parent.geometry) ??\n\t\t\t\tgeometries.at(-1) ??\n\t\t\t\tbaseline.geometry\n\t\t\tparent.material =\n\t\t\t\tactiveMaterials[0] ??\n\t\t\t\tmaterials.find((material) => material === parent.material) ??\n\t\t\t\tmaterials.at(-1) ??\n\t\t\t\tbaseline.material\n\t\t\tif (!owned && children.length === 0)\n\t\t\t\tborrowedDrawableDefaults.delete(parent)\n\t\t}\n\t},\n\tdestroy(node) {\n\t\teventHandlers.get(node)!.clear()\n\t\tif (node instanceof THREE.Object3D) {\n\t\t\ttry {\n\t\t\t\tforgetThree(node)\n\t\t\t} finally {\n\t\t\t\tnode.removeFromParent()\n\t\t\t\tif (node instanceof THREE.Mesh || node instanceof THREE.LineSegments) {\n\t\t\t\t\tconst owned = drawableDefaults.get(node)!\n\t\t\t\t\tif (owned.ownsGeometry) owned.geometry.dispose()\n\t\t\t\t\tif (owned.ownsMaterial) (owned.material as THREE.Material).dispose()\n\t\t\t\t}\n\t\t\t}\n\t\t} else node.dispose()\n\t},\n})\nfunction equalArgs(a: unknown[], b: unknown[] = []): boolean {\n\treturn (\n\t\ta.length === b.length &&\n\t\ta.every(\n\t\t\t(value, index) =>\n\t\t\t\tObject.is(value, b[index]) ||\n\t\t\t\t(Array.isArray(value) &&\n\t\t\t\t\tArray.isArray(b[index]) &&\n\t\t\t\t\tequalArgs(value, b[index])),\n\t\t)\n\t)\n}\n\nexport interface CanvasState {\n\tscene: THREE.Scene\n\tcamera: THREE.Camera\n\trenderer: THREE.WebGLRenderer\n}\nexport interface CanvasResizeState extends CanvasState {\n\twidth: number\n\theight: number\n\tdpr: number\n}\nexport interface CanvasProps {\n\tchildren?: Children\n\twidth?: number\n\theight?: number\n\tcamera?: THREE.Camera\n\t/** Constructor-time options. Canvas always supplies its own DOM canvas. */\n\trendererOptions?: Omit<THREE.WebGLRendererParameters, `canvas`>\n\t/** The returned renderer belongs exclusively to Canvas and is disposed with it. */\n\tcreateRenderer?: (\n\t\toptions: THREE.WebGLRendererParameters,\n\t) => THREE.WebGLRenderer\n\t/** Handle renderer creation failure locally, for example by offering an accessible fallback. */\n\tonError?: (error: unknown) => void\n\t/** A fixed ratio, or a device-pixel-ratio clamp. Defaults to 1. */\n\tdpr?: number | readonly [min: number, max: number]\n\t/** Runs after sizing and scene mounting, before the first draw. May return cleanup. */\n\tonCreated?: (state: CanvasState) => void | (() => void)\n\t/** Supplied cameras keep their projection; update it explicitly here if desired. */\n\tonResize?: (state: CanvasResizeState) => void\n\t/** Skip an idle GPU draw. Frame callbacks and pointer updates still run. */\n\trenderWhen?: () => boolean\n\tonFrame?: (state: CanvasState & { delta: number; time: number }) => void\n}\n/** Browser-only scene boundary. The camera prop is borrowed and never disposed. */\nexport function Canvas(props: CanvasProps): SpaElement {\n\tlet canvas: HTMLCanvasElement | null = null\n\tonMount(() => {\n\t\tconst parameters: THREE.WebGLRendererParameters = {\n\t\t\tantialias: true,\n\t\t\t...props.rendererOptions,\n\t\t\tcanvas: canvas!,\n\t\t}\n\t\tlet webgl: THREE.WebGLRenderer\n\t\ttry {\n\t\t\twebgl = props.createRenderer\n\t\t\t\t? props.createRenderer(parameters)\n\t\t\t\t: new THREE.WebGLRenderer(parameters)\n\t\t} catch (error) {\n\t\t\tif (!props.onError) throw error\n\t\t\tprops.onError(error)\n\t\t\treturn\n\t\t}\n\t\tonCleanup(() => {\n\t\t\twebgl.dispose()\n\t\t})\n\t\tif (webgl.domElement !== canvas)\n\t\t\tthrow new Error(`spa/three: renderer must use the supplied Canvas element`)\n\t\tconst scene = new THREE.Scene()\n\t\tconst camera = new THREE.PerspectiveCamera(50, 1, 0.1, 1000)\n\t\tcamera.position.z = 5\n\t\tconst view = canvas.ownerDocument.defaultView!\n\t\tconst size = () => ({\n\t\t\twidth: props.width ?? 800,\n\t\t\theight: props.height ?? 600,\n\t\t\tdpr: props.dpr ?? 1,\n\t\t\tactive: props.camera ?? camera,\n\t\t})\n\t\tconst resize = ({ width, height, dpr, active }: ReturnType<typeof size>) => {\n\t\t\tconst range = typeof dpr === `number` ? [dpr, dpr] : dpr\n\t\t\tif (\n\t\t\t\t![width, height, ...range].every(\n\t\t\t\t\t(value) => Number.isFinite(value) && value > 0,\n\t\t\t\t) ||\n\t\t\t\trange[0] > range[1]\n\t\t\t)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`spa/three: dimensions and DPR must be positive with an ordered DPR range`,\n\t\t\t\t)\n\t\t\tconst ratio = Math.max(\n\t\t\t\trange[0],\n\t\t\t\tMath.min(range[1], view.devicePixelRatio || 1),\n\t\t\t)\n\t\t\twebgl.setPixelRatio(ratio)\n\t\t\twebgl.setSize(width, height)\n\t\t\tcamera.aspect = width / height\n\t\t\tcamera.updateProjectionMatrix()\n\t\t\tprops.onResize?.({\n\t\t\t\tscene,\n\t\t\t\tcamera: active,\n\t\t\t\trenderer: webgl,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\tdpr: ratio,\n\t\t\t})\n\t\t}\n\t\tbindScene(size, resize)\n\t\tconst scope = owner!\n\t\tconst resized = () => {\n\t\t\ttry {\n\t\t\t\tresize(size())\n\t\t\t} catch (error) {\n\t\t\t\treportScopeError(scope, error)\n\t\t\t}\n\t\t}\n\t\tview.addEventListener(`resize`, resized)\n\t\tonCleanup(() => {\n\t\t\tview.removeEventListener(`resize`, resized)\n\t\t})\n\t\trenderer.mount(() => props.children, scene)\n\t\tconst events = createThreeEvents(\n\t\t\tcanvas,\n\t\t\tscene,\n\t\t\t() => props.camera ?? camera,\n\t\t\t(error) => {\n\t\t\t\treportScopeError(scope, error)\n\t\t\t},\n\t\t)\n\t\tonCleanup(() => {\n\t\t\tevents.dispose()\n\t\t})\n\t\t// Scene mounting queues child refs and mount hooks; setup must follow them.\n\t\tonMount(() => {\n\t\t\tconst cleanup = props.onCreated?.({\n\t\t\t\tscene,\n\t\t\t\tcamera: props.camera ?? camera,\n\t\t\t\trenderer: webgl,\n\t\t\t})\n\t\t\tif (cleanup) onCleanup(cleanup)\n\t\t\tlet last: number | undefined\n\t\t\tonSceneFrame((time) => {\n\t\t\t\tconst active = props.camera ?? camera\n\t\t\t\tconst delta = last === undefined ? 0 : (time - last) / 1000\n\t\t\t\tlast = time\n\t\t\t\tconst present = isPresent(scope)\n\t\t\t\tconst draw = !present || (props.renderWhen?.() ?? true)\n\t\t\t\tif (present)\n\t\t\t\t\tprops.onFrame?.({\n\t\t\t\t\t\tscene,\n\t\t\t\t\t\tcamera: active,\n\t\t\t\t\t\trenderer: webgl,\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t\ttime: time / 1000,\n\t\t\t\t\t})\n\t\t\t\tevents.update()\n\t\t\t\tif (draw) webgl.render(scene, active)\n\t\t\t}, true)\n\t\t})\n\t})\n\treturn jsx(`canvas`, {\n\t\tref: (element: HTMLCanvasElement | null) => {\n\t\t\tcanvas = element\n\t\t},\n\t})\n}\nexport const Group = sceneComponent<ObjectProps>(`Group`)\nexport const Mesh = sceneComponent<\n\tObjectProps<THREE.Mesh> & {\n\t\targs?: ConstructorParameters<typeof THREE.Mesh>\n\t}\n>(`Mesh`)\nexport const PerspectiveCamera = sceneComponent<\n\tObjectProps<THREE.PerspectiveCamera> & {\n\t\targs?: ConstructorParameters<typeof THREE.PerspectiveCamera>\n\t\tfov?: number\n\t\taspect?: number\n\t\tnear?: number\n\t\tfar?: number\n\t}\n>(`PerspectiveCamera`)\nexport const AmbientLight = sceneComponent<\n\tObjectProps<THREE.Light> & {\n\t\tcolor?: THREE.ColorRepresentation\n\t\tintensity?: number\n\t}\n>(`AmbientLight`)\nexport const DirectionalLight = sceneComponent<\n\tObjectProps<THREE.Light> & {\n\t\tcolor?: THREE.ColorRepresentation\n\t\tintensity?: number\n\t}\n>(`DirectionalLight`)\nexport const PointLight = sceneComponent<\n\tObjectProps<THREE.PointLight> & {\n\t\tcolor?: THREE.ColorRepresentation\n\t\tintensity?: number\n\t\tdistance?: number\n\t\tdecay?: number\n\t}\n>(`PointLight`)\nexport const BoxGeometry = sceneComponent<{\n\targs?: ConstructorParameters<typeof THREE.BoxGeometry>\n\tref?: (node: THREE.BoxGeometry | null) => void\n}>(`BoxGeometry`)\nexport const SphereGeometry = sceneComponent<{\n\targs?: ConstructorParameters<typeof THREE.SphereGeometry>\n\tref?: (node: THREE.SphereGeometry | null) => void\n}>(`SphereGeometry`)\nexport const PlaneGeometry = sceneComponent<{\n\targs?: ConstructorParameters<typeof THREE.PlaneGeometry>\n\tref?: (node: THREE.PlaneGeometry | null) => void\n}>(`PlaneGeometry`)\nexport const MeshStandardMaterial = sceneComponent<\n\tTHREE.MeshStandardMaterialParameters &\n\t\tCapabilityAttributes<`three`> & {\n\t\t\tref?: (node: THREE.MeshStandardMaterial | null) => void\n\t\t}\n>(`MeshStandardMaterial`)\nexport const MeshBasicMaterial = sceneComponent<\n\tTHREE.MeshBasicMaterialParameters &\n\t\tCapabilityAttributes<`three`> & {\n\t\t\tref?: (node: THREE.MeshBasicMaterial | null) => void\n\t\t}\n>(`MeshBasicMaterial`)\nexport const MeshNormalMaterial = sceneComponent<\n\tTHREE.MeshNormalMaterialParameters &\n\t\tCapabilityAttributes<`three`> & {\n\t\t\tref?: (node: THREE.MeshNormalMaterial | null) => void\n\t\t}\n>(`MeshNormalMaterial`)\nexport { renderer as threeRenderer }\n\n/** Batched line geometry, with the same attachment and ownership rules as Mesh. */\nexport const LineSegments = sceneComponent<\n\tObjectProps<THREE.LineSegments> & {\n\t\targs?: ConstructorParameters<typeof THREE.LineSegments>\n\t\tfrustumCulled?: boolean\n\t}\n>(`LineSegments`)\nexport const BufferGeometry = sceneComponent<{\n\tref?: (node: THREE.BufferGeometry | null) => void\n}>(`BufferGeometry`)\nexport const LineBasicMaterial = sceneComponent<\n\tTHREE.LineBasicMaterialParameters & {\n\t\tref?: (node: THREE.LineBasicMaterial | null) => void\n\t}\n>(`LineBasicMaterial`)\n"],"mappings":";;;;;AAsCA,MAAM,4BAAY,IAAI,QAAwB;AAC9C,SAAgB,aAAa,MAAkC;CAC9D,UAAU,IAAI,IAAI;CAClB,KAAK,MAAM,WAAW,UAAU,QAAQ,OAAO,IAAI;CACnD,aAAa;EACZ,UAAU,OAAO,IAAI;CACtB;AACD;AACA,MAAM,4BAAY,IAAI,QAAmD;AACzE,MAAM,2BAAW,IAAI,IAA4C;AAEjE,SAAgB,YACf,MACA,MACA,SACa;CACb,MAAM,SAAS,UAAU,IAAI,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Q,MAAM,UAAU;IACxB,UAAU;GACX,CAAC;GACD,IAAI,SAAS,UAAU,OAAO;GAC9B,IAAI;GACJ,cAAc,SAAS;IACtB,MAAM,SAAS,MAAM,UAAU;IAC/B,MAAM,QAAQ,SAAS,KAAA,IAAY,KAAK,OAAO,QAAQ;IACvD,OAAO;IACP,MAAM,UAAU,UAAU,KAAK;IAC/B,MAAM,OAAO,CAAC,YAAY,MAAM,aAAa,KAAK;IAClD,IAAI,SACH,MAAM,UAAU;KACf;KACA,QAAQ;KACR,UAAU;KACV;KACA,MAAM,OAAO;IACd,CAAC;IACF,OAAO,OAAO;IACd,IAAI,MAAM,MAAM,OAAO,OAAO,MAAM;GACrC,GAAG,IAAI;EACR,CAAC;CACF,CAAC;CACD,OAAO,IAAI,UAAU,EACpB,MAAM,YAAsC;EAC3C,SAAS;CACV,EACD,CAAC;AACF;AACA,MAAa,QAAQ,eAA4B,OAAO;AACxD,MAAa,OAAO,eAIlB,MAAM;AACR,MAAa,oBAAoB,eAQ/B,mBAAmB;AACrB,MAAa,eAAe,eAK1B,cAAc;AAChB,MAAa,mBAAmB,eAK9B,kBAAkB;AACpB,MAAa,aAAa,eAOxB,YAAY;AACd,MAAa,cAAc,eAGxB,aAAa;AAChB,MAAa,iBAAiB,eAG3B,gBAAgB;AACnB,MAAa,gBAAgB,eAG1B,eAAe;AAClB,MAAa,uBAAuB,eAKlC,sBAAsB;AACxB,MAAa,oBAAoB,eAK/B,mBAAmB;AACrB,MAAa,qBAAqB,eAKhC,oBAAoB;;AAItB,MAAa,eAAe,eAK1B,cAAc;AAChB,MAAa,iBAAiB,eAE3B,gBAAgB;AACnB,MAAa,oBAAoB,eAI/B,mBAAmB"}
|
package/dist/three.d.ts
CHANGED
|
@@ -72,12 +72,16 @@ export interface CanvasProps {
|
|
|
72
72
|
rendererOptions?: Omit<THREE.WebGLRendererParameters, `canvas`>;
|
|
73
73
|
/** The returned renderer belongs exclusively to Canvas and is disposed with it. */
|
|
74
74
|
createRenderer?: (options: THREE.WebGLRendererParameters) => THREE.WebGLRenderer;
|
|
75
|
+
/** Handle renderer creation failure locally, for example by offering an accessible fallback. */
|
|
76
|
+
onError?: (error: unknown) => void;
|
|
75
77
|
/** A fixed ratio, or a device-pixel-ratio clamp. Defaults to 1. */
|
|
76
78
|
dpr?: number | readonly [min: number, max: number];
|
|
77
79
|
/** Runs after sizing and scene mounting, before the first draw. May return cleanup. */
|
|
78
80
|
onCreated?: (state: CanvasState) => void | (() => void);
|
|
79
81
|
/** Supplied cameras keep their projection; update it explicitly here if desired. */
|
|
80
82
|
onResize?: (state: CanvasResizeState) => void;
|
|
83
|
+
/** Skip an idle GPU draw. Frame callbacks and pointer updates still run. */
|
|
84
|
+
renderWhen?: () => boolean;
|
|
81
85
|
onFrame?: (state: CanvasState & {
|
|
82
86
|
delta: number;
|
|
83
87
|
time: number;
|
|
@@ -104,6 +108,12 @@ export declare const DirectionalLight: (props: ObjectProps<THREE.Light> & {
|
|
|
104
108
|
color?: THREE.ColorRepresentation;
|
|
105
109
|
intensity?: number;
|
|
106
110
|
}) => SpaElement;
|
|
111
|
+
export declare const PointLight: (props: ObjectProps<THREE.PointLight> & {
|
|
112
|
+
color?: THREE.ColorRepresentation;
|
|
113
|
+
intensity?: number;
|
|
114
|
+
distance?: number;
|
|
115
|
+
decay?: number;
|
|
116
|
+
}) => SpaElement;
|
|
107
117
|
export declare const BoxGeometry: (props: {
|
|
108
118
|
args?: ConstructorParameters<typeof THREE.BoxGeometry>;
|
|
109
119
|
ref?: (node: THREE.BoxGeometry | null) => void;
|
|
@@ -125,5 +135,16 @@ export declare const MeshBasicMaterial: (props: THREE.MeshBasicMaterialParameter
|
|
|
125
135
|
export declare const MeshNormalMaterial: (props: THREE.MeshNormalMaterialParameters & CapabilityAttributes<"three"> & {
|
|
126
136
|
ref?: (node: THREE.MeshNormalMaterial | null) => void;
|
|
127
137
|
}) => SpaElement;
|
|
138
|
+
/** Batched line geometry, with the same attachment and ownership rules as Mesh. */
|
|
139
|
+
export declare const LineSegments: (props: ObjectProps<THREE.LineSegments<THREE.BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>, THREE.Material<THREE.MaterialEventMap>[] | THREE.Material<THREE.MaterialEventMap>, THREE.Object3DEventMap>> & {
|
|
140
|
+
args?: ConstructorParameters<typeof THREE.LineSegments>;
|
|
141
|
+
frustumCulled?: boolean;
|
|
142
|
+
}) => SpaElement;
|
|
143
|
+
export declare const BufferGeometry: (props: {
|
|
144
|
+
ref?: (node: THREE.BufferGeometry | null) => void;
|
|
145
|
+
}) => SpaElement;
|
|
146
|
+
export declare const LineBasicMaterial: (props: THREE.LineBasicMaterialParameters & {
|
|
147
|
+
ref?: (node: THREE.LineBasicMaterial | null) => void;
|
|
148
|
+
}) => SpaElement;
|
|
128
149
|
export { type ThreeEventAttributes, type ThreeEventHandler, type ThreeEventManager, type ThreePointerEvent, renderer as threeRenderer };
|
|
129
150
|
//# sourceMappingURL=three.d.ts.map
|
package/dist/three.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"three.d.ts","names":["_$__renderer_ts0.SceneRenderer"],"sources":["../src/three-events.ts","../src/three.ts"],"mappings":";;;;;UAEiB,kBAAkB,UAAU,MAAM,WAAW,MAAM;EACnE;EACA,aAAa;EACb,QAAQ,MAAM;EACd,eAAe;EACf,cAAc,MAAM;EACpB,KAAK,MAAM;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAEW,kBAAkB,UAAU,MAAM,WAAW,MAAM,aAC9D,OAAO,kBAAkB;UAET,qBAChB,UAAU,MAAM,WAAW,MAAM;EAEjC,gBAAgB,kBAAkB;EAClC,cAAc,kBAAkB;EAChC,gBAAgB,kBAAkB;EAClC,iBAAiB,kBAAkB;EACnC,iBAAiB,kBAAkB;EACnC,gBAAgB,kBAAkB;EAClC,eAAe,kBAAkB;EACjC,kBAAkB,kBAAkB;EACpC,UAAU,kBAAkB;;UA2CZ;EAChB;;EAEA,OAAO,MAAM,MAAM;EACnB;;;wBAIe,kBACf,QAAQ,mBACR,OAAO,MAAM,UACb,cAAc,MAAM,QACpB,WAAU,0BAGR;KC/DE,WAAW,MAAM,WAAW,MAAM,iBAAiB,MAAM;KACzD;iBACY,YAAY,UAAU,MAAM,WAAW,MAAM,kBACrD,+BAA+B,qBAAqB;EAC5D,WAAW;EACX,WAAW;EACX,WAAW;EACX,QAAQ;EACR;EACA;EACA,OAAO,QAAQ;;
|
|
1
|
+
{"version":3,"file":"three.d.ts","names":["_$__renderer_ts0.SceneRenderer"],"sources":["../src/three-events.ts","../src/three.ts"],"mappings":";;;;;UAEiB,kBAAkB,UAAU,MAAM,WAAW,MAAM;EACnE;EACA,aAAa;EACb,QAAQ,MAAM;EACd,eAAe;EACf,cAAc,MAAM;EACpB,KAAK,MAAM;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAEW,kBAAkB,UAAU,MAAM,WAAW,MAAM,aAC9D,OAAO,kBAAkB;UAET,qBAChB,UAAU,MAAM,WAAW,MAAM;EAEjC,gBAAgB,kBAAkB;EAClC,cAAc,kBAAkB;EAChC,gBAAgB,kBAAkB;EAClC,iBAAiB,kBAAkB;EACnC,iBAAiB,kBAAkB;EACnC,gBAAgB,kBAAkB;EAClC,eAAe,kBAAkB;EACjC,kBAAkB,kBAAkB;EACpC,UAAU,kBAAkB;;UA2CZ;EAChB;;EAEA,OAAO,MAAM,MAAM;EACnB;;;wBAIe,kBACf,QAAQ,mBACR,OAAO,MAAM,UACb,cAAc,MAAM,QACpB,WAAU,0BAGR;KC/DE,WAAW,MAAM,WAAW,MAAM,iBAAiB,MAAM;KACzD;iBACY,YAAY,UAAU,MAAM,WAAW,MAAM,kBACrD,+BAA+B,qBAAqB;EAC5D,WAAW;EACX,WAAW;EACX,WAAW;EACX,QAAQ;EACR;EACA;EACA,OAAO,QAAQ;;cAmDV,UAAQA,cAAA;iBA4LG;EAChB,OAAO,MAAM;EACb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,OAAA,YAAA,MAAA,aAAA,MAAA,eAAA,MAAA,wBAAA,MAAA,yBAAA,MAAA,SAAA,MAAA,sBAAA,MAAA,SAAA,MAAA,mBAAA,MAAA;EAEhB,OAAA,6BAA6B,MAAM;EAC1B;MAED;qBACJ,iBAAc;EACpB,OAAC,MAAM,MAAM;MACA;qBACP,oBAAiB,OAAA,MAAA;EAEtB,OAAC,MAAM,MAAM;MAEC"}
|
package/dist/three.js
CHANGED
|
@@ -1,509 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { n as jsx } from "./jsx-runtime-BGDPK50B.js";
|
|
3
|
-
import { bindScene, createSceneRenderer, onSceneFrame, sceneComponent } from "./renderer.js";
|
|
4
|
-
import * as THREE from "three";
|
|
5
|
-
// src/three-events.ts
|
|
6
|
-
const suspended = /* @__PURE__ */ new WeakSet();
|
|
7
|
-
function suspendThree(node) {
|
|
8
|
-
suspended.add(node);
|
|
9
|
-
for (const manager of managers) manager.remove(node);
|
|
10
|
-
return () => {
|
|
11
|
-
suspended.delete(node);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
const listeners = /* @__PURE__ */ new WeakMap();
|
|
15
|
-
const managers = /* @__PURE__ */ new Set();
|
|
16
|
-
function listenThree(node, type, handler) {
|
|
17
|
-
const events = listeners.get(node) ?? /* @__PURE__ */ new Map();
|
|
18
|
-
listeners.set(node, events);
|
|
19
|
-
const handlers = events.get(type) ?? /* @__PURE__ */ new Set();
|
|
20
|
-
events.set(type, handlers);
|
|
21
|
-
handlers.add(handler);
|
|
22
|
-
return () => {
|
|
23
|
-
handlers.delete(handler);
|
|
24
|
-
if (!handlers.size) events.delete(type);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function forgetThree(node) {
|
|
28
|
-
const errors = [];
|
|
29
|
-
for (const manager of managers) try {
|
|
30
|
-
manager.remove(node);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
errors.push(error);
|
|
33
|
-
}
|
|
34
|
-
listeners.delete(node);
|
|
35
|
-
if (errors.length) throw new AggregateError(errors);
|
|
36
|
-
}
|
|
37
|
-
/** Attach raycast pointer routing to a canvas; usable with borrowed scene roots. */
|
|
38
|
-
function createThreeEvents(canvas, scene, camera, onError = (error) => {
|
|
39
|
-
throw error;
|
|
40
|
-
}) {
|
|
41
|
-
const raycaster = new THREE.Raycaster();
|
|
42
|
-
const pointer = new THREE.Vector2();
|
|
43
|
-
const hovering = /* @__PURE__ */ new Map();
|
|
44
|
-
const pressed = /* @__PURE__ */ new Map();
|
|
45
|
-
const captures = /* @__PURE__ */ new Map();
|
|
46
|
-
const last = /* @__PURE__ */ new Map();
|
|
47
|
-
let dead = false;
|
|
48
|
-
const path = (node) => {
|
|
49
|
-
const nodes = [];
|
|
50
|
-
for (let at = node; at; at = at.parent) {
|
|
51
|
-
nodes.push(at);
|
|
52
|
-
if (at === scene) return nodes;
|
|
53
|
-
}
|
|
54
|
-
return [];
|
|
55
|
-
};
|
|
56
|
-
const contains = (node, child) => {
|
|
57
|
-
for (let at = child; at; at = at.parent) if (at === node) return true;
|
|
58
|
-
return false;
|
|
59
|
-
};
|
|
60
|
-
const eligible = (intersection) => {
|
|
61
|
-
const nodes = path(intersection.object);
|
|
62
|
-
if (!nodes.length || nodes.some((node) => !node.visible || suspended.has(node))) return false;
|
|
63
|
-
const material = intersection.object.material;
|
|
64
|
-
return !material || (Array.isArray(material) ? material[intersection.face?.materialIndex ?? 0]?.visible !== false : material.visible);
|
|
65
|
-
};
|
|
66
|
-
const pick = (event) => {
|
|
67
|
-
const bounds = canvas.getBoundingClientRect();
|
|
68
|
-
if (!bounds.width || !bounds.height) return void 0;
|
|
69
|
-
const active = camera();
|
|
70
|
-
scene.updateWorldMatrix(true, true);
|
|
71
|
-
active.updateWorldMatrix(true, false);
|
|
72
|
-
pointer.set((event.clientX - bounds.left) / bounds.width * 2 - 1, 1 - (event.clientY - bounds.top) / bounds.height * 2);
|
|
73
|
-
raycaster.layers.mask = active.layers.mask;
|
|
74
|
-
raycaster.setFromCamera(pointer, active);
|
|
75
|
-
if (event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom) return void 0;
|
|
76
|
-
const intersection = raycaster.intersectObject(scene, true).find(eligible);
|
|
77
|
-
return intersection ? {
|
|
78
|
-
node: intersection.object,
|
|
79
|
-
intersection
|
|
80
|
-
} : void 0;
|
|
81
|
-
};
|
|
82
|
-
const nativeCapture = (id) => {
|
|
83
|
-
if (canvas.hasPointerCapture?.(id)) canvas.releasePointerCapture(id);
|
|
84
|
-
};
|
|
85
|
-
const dispatch = (type, hit, nativeEvent, nodes = path(hit.node)) => {
|
|
86
|
-
let stopped = false;
|
|
87
|
-
for (const node of nodes) {
|
|
88
|
-
if (dead) break;
|
|
89
|
-
const event = {
|
|
90
|
-
type,
|
|
91
|
-
nativeEvent,
|
|
92
|
-
target: hit.node,
|
|
93
|
-
currentTarget: node,
|
|
94
|
-
intersection: hit.intersection,
|
|
95
|
-
ray: raycaster.ray.clone(),
|
|
96
|
-
pointerId: nativeEvent.pointerId,
|
|
97
|
-
button: nativeEvent.button,
|
|
98
|
-
buttons: nativeEvent.buttons,
|
|
99
|
-
clientX: nativeEvent.clientX,
|
|
100
|
-
clientY: nativeEvent.clientY,
|
|
101
|
-
stopPropagation() {
|
|
102
|
-
stopped = true;
|
|
103
|
-
},
|
|
104
|
-
preventDefault() {
|
|
105
|
-
nativeEvent.preventDefault();
|
|
106
|
-
},
|
|
107
|
-
setPointerCapture() {
|
|
108
|
-
canvas.setPointerCapture(nativeEvent.pointerId);
|
|
109
|
-
captures.set(nativeEvent.pointerId, {
|
|
110
|
-
node,
|
|
111
|
-
intersection: hit.intersection
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
releasePointerCapture() {
|
|
115
|
-
if (captures.get(nativeEvent.pointerId)?.node === node) {
|
|
116
|
-
captures.delete(nativeEvent.pointerId);
|
|
117
|
-
nativeCapture(nativeEvent.pointerId);
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
hasPointerCapture() {
|
|
121
|
-
return captures.get(nativeEvent.pointerId)?.node === node;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
for (const handler of [...listeners.get(node)?.get(type) ?? []]) if (!dead && listeners.get(node)?.get(type)?.has(handler)) handler(event);
|
|
125
|
-
if (stopped) break;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const hover = (event, next) => {
|
|
129
|
-
const previous = hovering.get(event.pointerId);
|
|
130
|
-
if (previous?.node === next?.node) {
|
|
131
|
-
if (next) hovering.set(event.pointerId, next);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const oldPath = previous ? path(previous.node) : [];
|
|
135
|
-
const newPath = next ? path(next.node) : [];
|
|
136
|
-
if (next) hovering.set(event.pointerId, next);
|
|
137
|
-
else hovering.delete(event.pointerId);
|
|
138
|
-
if (previous) {
|
|
139
|
-
dispatch(`pointerout`, previous, event);
|
|
140
|
-
for (const node of oldPath) if (!newPath.includes(node)) dispatch(`pointerleave`, previous, event, [node]);
|
|
141
|
-
}
|
|
142
|
-
if (next && path(next.node).length) {
|
|
143
|
-
dispatch(`pointerover`, next, event);
|
|
144
|
-
for (const node of newPath.reverse()) if (!oldPath.includes(node)) dispatch(`pointerenter`, next, event, [node]);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
const cancel = (event) => {
|
|
148
|
-
const hit = captures.get(event.pointerId) ?? pressed.get(event.pointerId);
|
|
149
|
-
captures.delete(event.pointerId);
|
|
150
|
-
pressed.delete(event.pointerId);
|
|
151
|
-
try {
|
|
152
|
-
if (hit) dispatch(`pointercancel`, hit, event);
|
|
153
|
-
} finally {
|
|
154
|
-
nativeCapture(event.pointerId);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
const handle = (event) => {
|
|
158
|
-
try {
|
|
159
|
-
if (event.type === `lostpointercapture`) {
|
|
160
|
-
cancel(event);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
if (event.type === `pointercancel`) {
|
|
164
|
-
cancel(event);
|
|
165
|
-
hover(event);
|
|
166
|
-
last.delete(event.pointerId);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (event.type === `pointerleave`) {
|
|
170
|
-
last.set(event.pointerId, event);
|
|
171
|
-
hover(event);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
last.set(event.pointerId, event);
|
|
175
|
-
const hit = pick(event);
|
|
176
|
-
hover(event, hit);
|
|
177
|
-
if (dead) return;
|
|
178
|
-
const capture = captures.get(event.pointerId);
|
|
179
|
-
if (capture && hit && contains(capture.node, hit.node)) capture.intersection = hit.intersection;
|
|
180
|
-
const delivery = capture ?? hit;
|
|
181
|
-
if (event.type === `pointerdown`) {
|
|
182
|
-
if (hit) {
|
|
183
|
-
pressed.set(event.pointerId, hit);
|
|
184
|
-
canvas.setPointerCapture?.(event.pointerId);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
if (event.type === `pointerup`) {
|
|
188
|
-
const down = pressed.get(event.pointerId);
|
|
189
|
-
pressed.delete(event.pointerId);
|
|
190
|
-
try {
|
|
191
|
-
if (down && !capture && down.node !== hit?.node) dispatch(`pointercancel`, down, event);
|
|
192
|
-
if (delivery) dispatch(`pointerup`, delivery, event);
|
|
193
|
-
if (down && down.node === hit?.node && event.button === 0) dispatch(`click`, hit, event);
|
|
194
|
-
} finally {
|
|
195
|
-
captures.delete(event.pointerId);
|
|
196
|
-
nativeCapture(event.pointerId);
|
|
197
|
-
if (event.pointerType === `touch`) {
|
|
198
|
-
hover(event);
|
|
199
|
-
last.delete(event.pointerId);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
} else if (delivery) dispatch(event.type, delivery, event);
|
|
203
|
-
} catch (error) {
|
|
204
|
-
onError(error);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
const events = [
|
|
208
|
-
`pointerdown`,
|
|
209
|
-
`pointerup`,
|
|
210
|
-
`pointermove`,
|
|
211
|
-
`pointerleave`,
|
|
212
|
-
`pointercancel`,
|
|
213
|
-
`lostpointercapture`
|
|
214
|
-
];
|
|
215
|
-
for (const type of events) canvas.addEventListener(type, handle);
|
|
216
|
-
const manager = {
|
|
217
|
-
/** Re-pick stationary pointers after camera, geometry, or transforms change. */
|
|
218
|
-
update() {
|
|
219
|
-
if (dead) return;
|
|
220
|
-
try {
|
|
221
|
-
for (const event of last.values()) if (event.type !== `pointerleave`) hover(event, pick(event));
|
|
222
|
-
} catch (error) {
|
|
223
|
-
onError(error);
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
remove(node) {
|
|
227
|
-
const errors = [];
|
|
228
|
-
for (const [id, hit] of hovering) if (contains(node, hit.node)) try {
|
|
229
|
-
hover(last.get(id));
|
|
230
|
-
} catch (error) {
|
|
231
|
-
errors.push(error);
|
|
232
|
-
}
|
|
233
|
-
for (const [id, hit] of [...pressed, ...captures]) if (contains(node, hit.node)) try {
|
|
234
|
-
cancel(last.get(id));
|
|
235
|
-
} catch (error) {
|
|
236
|
-
errors.push(error);
|
|
237
|
-
}
|
|
238
|
-
if (errors.length) throw new AggregateError(errors);
|
|
239
|
-
},
|
|
240
|
-
dispose() {
|
|
241
|
-
if (dead) return;
|
|
242
|
-
dead = true;
|
|
243
|
-
for (const type of events) canvas.removeEventListener(type, handle);
|
|
244
|
-
for (const id of /* @__PURE__ */ new Set([...pressed.keys(), ...captures.keys()])) nativeCapture(id);
|
|
245
|
-
hovering.clear();
|
|
246
|
-
pressed.clear();
|
|
247
|
-
captures.clear();
|
|
248
|
-
last.clear();
|
|
249
|
-
managers.delete(manager);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
managers.add(manager);
|
|
253
|
-
return manager;
|
|
254
|
-
}
|
|
255
|
-
// src/three.ts
|
|
256
|
-
const constructors = {
|
|
257
|
-
Group: THREE.Group,
|
|
258
|
-
Mesh: THREE.Mesh,
|
|
259
|
-
PerspectiveCamera: THREE.PerspectiveCamera,
|
|
260
|
-
AmbientLight: THREE.AmbientLight,
|
|
261
|
-
DirectionalLight: THREE.DirectionalLight,
|
|
262
|
-
BoxGeometry: THREE.BoxGeometry,
|
|
263
|
-
SphereGeometry: THREE.SphereGeometry,
|
|
264
|
-
PlaneGeometry: THREE.PlaneGeometry,
|
|
265
|
-
MeshStandardMaterial: THREE.MeshStandardMaterial,
|
|
266
|
-
MeshBasicMaterial: THREE.MeshBasicMaterial,
|
|
267
|
-
MeshNormalMaterial: THREE.MeshNormalMaterial
|
|
268
|
-
};
|
|
269
|
-
const meshDefaults = /* @__PURE__ */ new WeakMap();
|
|
270
|
-
const borrowedMeshDefaults = /* @__PURE__ */ new WeakMap();
|
|
271
|
-
const constructorArgs = /* @__PURE__ */ new WeakMap();
|
|
272
|
-
const eventHandlers = /* @__PURE__ */ new WeakMap();
|
|
273
|
-
const defaults = /* @__PURE__ */ new WeakMap();
|
|
274
|
-
function writeProperty(node, key, value) {
|
|
275
|
-
const target = node;
|
|
276
|
-
if (!(key in target)) throw new Error(`spa/three: unknown property ${key}`);
|
|
277
|
-
const current = target[key];
|
|
278
|
-
if (current?.isColor) current.set(value);
|
|
279
|
-
else if (Array.isArray(value) && typeof current?.set === `function`) current.set(...value);
|
|
280
|
-
else if (key === `scale` && typeof value === `number`) current.setScalar(value);
|
|
281
|
-
else if (current?.copy && value?.constructor === current.constructor) current.copy(value);
|
|
282
|
-
else target[key] = value;
|
|
283
|
-
if (node instanceof THREE.PerspectiveCamera) node.updateProjectionMatrix();
|
|
284
|
-
}
|
|
285
|
-
const renderer = createSceneRenderer({
|
|
286
|
-
target(node) {
|
|
287
|
-
return {
|
|
288
|
-
kind: `three`,
|
|
289
|
-
node,
|
|
290
|
-
...node instanceof THREE.Object3D ? {
|
|
291
|
-
suspend: () => suspendThree(node),
|
|
292
|
-
listen: (type, listener) => listenThree(node, type, listener)
|
|
293
|
-
} : {},
|
|
294
|
-
read(key) {
|
|
295
|
-
const value = node[key];
|
|
296
|
-
return value?.isColor ? value.getStyle() : value?.isVector3 || value?.isEuler ? [
|
|
297
|
-
value.x,
|
|
298
|
-
value.y,
|
|
299
|
-
value.z
|
|
300
|
-
] : value;
|
|
301
|
-
},
|
|
302
|
-
write(key, value) {
|
|
303
|
-
writeProperty(node, key, value);
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
},
|
|
307
|
-
create(type, props) {
|
|
308
|
-
const Constructor = constructors[type];
|
|
309
|
-
if (!Constructor) throw new Error(`spa/three: unknown node ${type}`);
|
|
310
|
-
const node = new Constructor(...props[`args`] ?? []);
|
|
311
|
-
if (node instanceof THREE.Mesh) meshDefaults.set(node, {
|
|
312
|
-
geometry: node.geometry,
|
|
313
|
-
material: node.material,
|
|
314
|
-
ownsGeometry: props[`args`]?.[0] === void 0,
|
|
315
|
-
ownsMaterial: props[`args`]?.[1] === void 0
|
|
316
|
-
});
|
|
317
|
-
constructorArgs.set(node, [...props[`args`] ?? []]);
|
|
318
|
-
defaults.set(node, /* @__PURE__ */ new Map());
|
|
319
|
-
eventHandlers.set(node, /* @__PURE__ */ new Map());
|
|
320
|
-
return node;
|
|
321
|
-
},
|
|
322
|
-
update(node, props, previous) {
|
|
323
|
-
if (!equalArgs(constructorArgs.get(node), props[`args`])) throw new Error(`spa/three: change the component key to replace constructor args`);
|
|
324
|
-
const target = node;
|
|
325
|
-
const saved = defaults.get(node);
|
|
326
|
-
for (const key of /* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(props)])) {
|
|
327
|
-
if (/^(key|children|ref|args)$/.test(key) || Object.is(props[key], previous[key])) continue;
|
|
328
|
-
if (key.startsWith(`on`)) {
|
|
329
|
-
if (!(node instanceof THREE.Object3D) || !/^on(Pointer(Down|Up|Move|Enter|Leave|Over|Out|Cancel)|Click)$/.test(key)) throw new Error(`spa/three: unknown event ${key}`);
|
|
330
|
-
const handlers = eventHandlers.get(node);
|
|
331
|
-
handlers.get(key)?.();
|
|
332
|
-
handlers.delete(key);
|
|
333
|
-
const handler = props[key];
|
|
334
|
-
if (handler) {
|
|
335
|
-
const scope = owner;
|
|
336
|
-
handlers.set(key, listenThree(node, key.slice(2).toLowerCase(), (event) => {
|
|
337
|
-
within(scope, () => {
|
|
338
|
-
handler(event);
|
|
339
|
-
});
|
|
340
|
-
}));
|
|
341
|
-
}
|
|
342
|
-
continue;
|
|
343
|
-
}
|
|
344
|
-
if (!(key in target)) throw new Error(`spa/three: unknown property ${key}`);
|
|
345
|
-
const current = target[key];
|
|
346
|
-
if (!saved.has(key)) saved.set(key, current?.clone ? current.clone() : current);
|
|
347
|
-
writeProperty(node, key, props[key] === void 0 ? saved.get(key) : props[key]);
|
|
348
|
-
}
|
|
349
|
-
if (node instanceof THREE.PerspectiveCamera) node.updateProjectionMatrix();
|
|
350
|
-
},
|
|
351
|
-
children(parent, children, activeChildren) {
|
|
352
|
-
if (!(parent instanceof THREE.Object3D)) {
|
|
353
|
-
if (children.length) throw new Error(`spa/three: resources cannot contain children`);
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
const objects = children.filter((child) => child instanceof THREE.Object3D);
|
|
357
|
-
if (parent.children.length !== objects.length || objects.some((child, index) => child !== parent.children[index])) {
|
|
358
|
-
const wanted = new Set(objects);
|
|
359
|
-
for (const child of [...parent.children]) if (!wanted.has(child)) parent.remove(child);
|
|
360
|
-
for (const child of objects) if (child.parent !== parent) parent.add(child);
|
|
361
|
-
parent.children.splice(0, parent.children.length, ...objects);
|
|
362
|
-
}
|
|
363
|
-
const resources = children.filter((child) => !(child instanceof THREE.Object3D));
|
|
364
|
-
if (resources.length && !(parent instanceof THREE.Mesh)) throw new Error(`spa/three: geometry and material require a Mesh parent`);
|
|
365
|
-
if (parent instanceof THREE.Mesh) {
|
|
366
|
-
const geometries = resources.filter((child) => child instanceof THREE.BufferGeometry);
|
|
367
|
-
const materials = resources.filter((child) => child instanceof THREE.Material);
|
|
368
|
-
const activeGeometries = activeChildren.filter((child) => child instanceof THREE.BufferGeometry);
|
|
369
|
-
const activeMaterials = activeChildren.filter((child) => child instanceof THREE.Material);
|
|
370
|
-
if (activeGeometries.length > 1 || activeMaterials.length > 1) throw new Error(`spa/three: each Mesh accepts one geometry and one material`);
|
|
371
|
-
const owned = meshDefaults.get(parent);
|
|
372
|
-
let baseline = owned ?? borrowedMeshDefaults.get(parent);
|
|
373
|
-
if (!baseline) {
|
|
374
|
-
baseline = {
|
|
375
|
-
geometry: parent.geometry,
|
|
376
|
-
material: parent.material
|
|
377
|
-
};
|
|
378
|
-
borrowedMeshDefaults.set(parent, baseline);
|
|
379
|
-
}
|
|
380
|
-
parent.geometry = activeGeometries[0] ?? geometries.find((geometry) => geometry === parent.geometry) ?? geometries.at(-1) ?? baseline.geometry;
|
|
381
|
-
parent.material = activeMaterials[0] ?? materials.find((material) => material === parent.material) ?? materials.at(-1) ?? baseline.material;
|
|
382
|
-
if (!owned && children.length === 0) borrowedMeshDefaults.delete(parent);
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
|
-
destroy(node) {
|
|
386
|
-
eventHandlers.get(node).clear();
|
|
387
|
-
if (node instanceof THREE.Object3D) try {
|
|
388
|
-
forgetThree(node);
|
|
389
|
-
} finally {
|
|
390
|
-
node.removeFromParent();
|
|
391
|
-
if (node instanceof THREE.Mesh) {
|
|
392
|
-
const owned = meshDefaults.get(node);
|
|
393
|
-
if (owned.ownsGeometry) owned.geometry.dispose();
|
|
394
|
-
if (owned.ownsMaterial) owned.material.dispose();
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
else node.dispose();
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
function equalArgs(a, b = []) {
|
|
401
|
-
return a.length === b.length && a.every((value, index) => Object.is(value, b[index]) || Array.isArray(value) && Array.isArray(b[index]) && equalArgs(value, b[index]));
|
|
402
|
-
}
|
|
403
|
-
/** Browser-only scene boundary. The camera prop is borrowed and never disposed. */
|
|
404
|
-
function Canvas(props) {
|
|
405
|
-
let canvas = null;
|
|
406
|
-
onMount(() => {
|
|
407
|
-
const parameters = {
|
|
408
|
-
antialias: true,
|
|
409
|
-
...props.rendererOptions,
|
|
410
|
-
canvas
|
|
411
|
-
};
|
|
412
|
-
const webgl = props.createRenderer ? props.createRenderer(parameters) : new THREE.WebGLRenderer(parameters);
|
|
413
|
-
onCleanup(() => {
|
|
414
|
-
webgl.dispose();
|
|
415
|
-
});
|
|
416
|
-
if (webgl.domElement !== canvas) throw new Error(`spa/three: renderer must use the supplied Canvas element`);
|
|
417
|
-
const scene = new THREE.Scene();
|
|
418
|
-
const camera = new THREE.PerspectiveCamera(50, 1, .1, 1e3);
|
|
419
|
-
camera.position.z = 5;
|
|
420
|
-
const view = canvas.ownerDocument.defaultView;
|
|
421
|
-
const size = () => ({
|
|
422
|
-
width: props.width ?? 800,
|
|
423
|
-
height: props.height ?? 600,
|
|
424
|
-
dpr: props.dpr ?? 1,
|
|
425
|
-
active: props.camera ?? camera
|
|
426
|
-
});
|
|
427
|
-
const resize = ({ width, height, dpr, active }) => {
|
|
428
|
-
const range = typeof dpr === `number` ? [dpr, dpr] : dpr;
|
|
429
|
-
if (![
|
|
430
|
-
width,
|
|
431
|
-
height,
|
|
432
|
-
...range
|
|
433
|
-
].every((value) => Number.isFinite(value) && value > 0) || range[0] > range[1]) throw new Error(`spa/three: dimensions and DPR must be positive with an ordered DPR range`);
|
|
434
|
-
const ratio = Math.max(range[0], Math.min(range[1], view.devicePixelRatio || 1));
|
|
435
|
-
webgl.setPixelRatio(ratio);
|
|
436
|
-
webgl.setSize(width, height);
|
|
437
|
-
camera.aspect = width / height;
|
|
438
|
-
camera.updateProjectionMatrix();
|
|
439
|
-
props.onResize?.({
|
|
440
|
-
scene,
|
|
441
|
-
camera: active,
|
|
442
|
-
renderer: webgl,
|
|
443
|
-
width,
|
|
444
|
-
height,
|
|
445
|
-
dpr: ratio
|
|
446
|
-
});
|
|
447
|
-
};
|
|
448
|
-
bindScene(size, resize);
|
|
449
|
-
const scope = owner;
|
|
450
|
-
const resized = () => {
|
|
451
|
-
try {
|
|
452
|
-
resize(size());
|
|
453
|
-
} catch (error) {
|
|
454
|
-
reportScopeError(scope, error);
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
view.addEventListener(`resize`, resized);
|
|
458
|
-
onCleanup(() => {
|
|
459
|
-
view.removeEventListener(`resize`, resized);
|
|
460
|
-
});
|
|
461
|
-
renderer.mount(() => props.children, scene);
|
|
462
|
-
const events = createThreeEvents(canvas, scene, () => props.camera ?? camera, (error) => {
|
|
463
|
-
reportScopeError(scope, error);
|
|
464
|
-
});
|
|
465
|
-
onCleanup(() => {
|
|
466
|
-
events.dispose();
|
|
467
|
-
});
|
|
468
|
-
onMount(() => {
|
|
469
|
-
const cleanup = props.onCreated?.({
|
|
470
|
-
scene,
|
|
471
|
-
camera: props.camera ?? camera,
|
|
472
|
-
renderer: webgl
|
|
473
|
-
});
|
|
474
|
-
if (cleanup) onCleanup(cleanup);
|
|
475
|
-
let last;
|
|
476
|
-
onSceneFrame((time) => {
|
|
477
|
-
const active = props.camera ?? camera;
|
|
478
|
-
const delta = last === void 0 ? 0 : (time - last) / 1e3;
|
|
479
|
-
last = time;
|
|
480
|
-
if (isPresent(scope)) props.onFrame?.({
|
|
481
|
-
scene,
|
|
482
|
-
camera: active,
|
|
483
|
-
renderer: webgl,
|
|
484
|
-
delta,
|
|
485
|
-
time: time / 1e3
|
|
486
|
-
});
|
|
487
|
-
events.update();
|
|
488
|
-
webgl.render(scene, active);
|
|
489
|
-
}, true);
|
|
490
|
-
});
|
|
491
|
-
});
|
|
492
|
-
return jsx(`canvas`, { ref: (element) => {
|
|
493
|
-
canvas = element;
|
|
494
|
-
} });
|
|
495
|
-
}
|
|
496
|
-
const Group = sceneComponent(`Group`);
|
|
497
|
-
const Mesh = sceneComponent(`Mesh`);
|
|
498
|
-
const PerspectiveCamera = sceneComponent(`PerspectiveCamera`);
|
|
499
|
-
const AmbientLight = sceneComponent(`AmbientLight`);
|
|
500
|
-
const DirectionalLight = sceneComponent(`DirectionalLight`);
|
|
501
|
-
const BoxGeometry = sceneComponent(`BoxGeometry`);
|
|
502
|
-
const SphereGeometry = sceneComponent(`SphereGeometry`);
|
|
503
|
-
const PlaneGeometry = sceneComponent(`PlaneGeometry`);
|
|
504
|
-
const MeshStandardMaterial = sceneComponent(`MeshStandardMaterial`);
|
|
505
|
-
const MeshBasicMaterial = sceneComponent(`MeshBasicMaterial`);
|
|
506
|
-
const MeshNormalMaterial = sceneComponent(`MeshNormalMaterial`);
|
|
507
|
-
export { AmbientLight, BoxGeometry, Canvas, DirectionalLight, Group, Mesh, MeshBasicMaterial, MeshNormalMaterial, MeshStandardMaterial, PerspectiveCamera, PlaneGeometry, SphereGeometry, createThreeEvents, renderer as threeRenderer };
|
|
508
|
-
|
|
509
|
-
//# sourceMappingURL=three.js.map
|
|
1
|
+
export { t as AmbientLight, n as BoxGeometry, r as BufferGeometry, i as Canvas, a as DirectionalLight, o as Group, s as LineBasicMaterial, c as LineSegments, l as Mesh, u as MeshBasicMaterial, d as MeshNormalMaterial, f as MeshStandardMaterial, p as PerspectiveCamera, m as PlaneGeometry, h as PointLight, g as SphereGeometry, v as createThreeEvents, _ as threeRenderer } from "./three-DcYxRXPW.js";
|