@mml-io/mml-web-threejs 0.19.2 → 0.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -843,10 +843,13 @@ var _ThreeJSImage = class _ThreeJSImage extends ImageGraphics {
843
843
  this.mesh.castShadow = castShadows;
844
844
  }
845
845
  setOpacity(opacity) {
846
- const needsUpdate = this.material.transparent === (opacity === 1);
847
- this.material.transparent = opacity !== 1;
848
- this.material.needsUpdate = needsUpdate;
846
+ const shouldBeTransparent = opacity !== 1 || this.loadedImageHasTransparency;
847
+ const needsUpdate = this.material.transparent !== shouldBeTransparent;
848
+ this.material.transparent = shouldBeTransparent;
849
849
  this.material.opacity = opacity;
850
+ if (needsUpdate) {
851
+ this.material.needsUpdate = true;
852
+ }
850
853
  }
851
854
  setEmissive() {
852
855
  this.updateMaterialEmissiveIntensity();
@@ -939,15 +942,9 @@ var _ThreeJSImage = class _ThreeJSImage extends ImageGraphics {
939
942
  if (!this.material) {
940
943
  return;
941
944
  }
942
- if (this.loadedImageHasTransparency) {
943
- this.material.alphaMap = new THREE7.CanvasTexture(this.loadedImage);
944
- this.material.alphaTest = 0.01;
945
- } else {
946
- this.material.alphaMap = null;
947
- this.material.alphaTest = 0;
948
- }
949
- this.material.transparent = this.image.props.opacity !== 1 || this.loadedImageHasTransparency;
950
945
  this.material.map = new THREE7.CanvasTexture(this.loadedImage);
946
+ this.material.transparent = this.image.props.opacity !== 1 || this.loadedImageHasTransparency;
947
+ this.material.alphaTest = 0.01;
951
948
  this.material.needsUpdate = true;
952
949
  this.updateMaterialEmissiveIntensity();
953
950
  this.updateWidthAndHeight();
@@ -1254,7 +1251,7 @@ var ThreeJSLight = class extends LightGraphics {
1254
1251
  this.threeLight.castShadow = this.light.props.castShadows;
1255
1252
  this.threeLight.shadow.mapSize.width = 512;
1256
1253
  this.threeLight.shadow.mapSize.height = 512;
1257
- if (this.threeLight.shadow.camera instanceof THREE10.PerspectiveCamera) {
1254
+ if (this.threeLight.shadow.camera.isPerspectiveCamera) {
1258
1255
  this.threeLight.shadow.camera.near = 0.5;
1259
1256
  this.threeLight.shadow.camera.far = 500;
1260
1257
  }
@@ -1309,7 +1306,7 @@ var ThreeJSLight = class extends LightGraphics {
1309
1306
  this.threeLight.castShadow = castShadows;
1310
1307
  }
1311
1308
  setAngle(angle) {
1312
- if (this.threeLight instanceof THREE10.SpotLight) {
1309
+ if (this.threeLight.isSpotLight) {
1313
1310
  this.threeLight.angle = THREE10.MathUtils.degToRad(angle);
1314
1311
  }
1315
1312
  }
@@ -1475,7 +1472,7 @@ var _ThreeJSModel = class _ThreeJSModel extends ModelGraphics {
1475
1472
  this.animLoadingInstanceManager.abortIfLoading();
1476
1473
  if (this.loadedState && !this.registeredParentAttachment) {
1477
1474
  const parent = this.model.parentElement;
1478
- if (parent instanceof Model) {
1475
+ if (parent && Model.isModel(parent)) {
1479
1476
  this.registeredParentAttachment = parent;
1480
1477
  parent.modelGraphics.registerAttachment(this.model);
1481
1478
  }
@@ -1592,7 +1589,7 @@ var _ThreeJSModel = class _ThreeJSModel extends ModelGraphics {
1592
1589
  }
1593
1590
  this.updateMeshCallback();
1594
1591
  const parent = this.model.parentElement;
1595
- if (parent instanceof Model) {
1592
+ if (parent && Model.isModel(parent)) {
1596
1593
  if (!this.latestAnimPromise && !this.animState) {
1597
1594
  this.registeredParentAttachment = parent;
1598
1595
  parent.modelGraphics.registerAttachment(this.model);
@@ -1712,7 +1709,7 @@ var _ThreeJSModel = class _ThreeJSModel extends ModelGraphics {
1712
1709
  triggerSocketedChildrenTransformed() {
1713
1710
  this.socketChildrenByBone.forEach((children) => {
1714
1711
  children.forEach((child) => {
1715
- if (child instanceof TransformableElement) {
1712
+ if (TransformableElement.isTransformableElement(child)) {
1716
1713
  child.didUpdateTransformation();
1717
1714
  }
1718
1715
  });
@@ -2473,7 +2470,7 @@ var ThreeJSClickTrigger = class _ThreeJSClickTrigger {
2473
2470
  break;
2474
2471
  }
2475
2472
  const mElement = MElement3.getMElementFromObject(obj);
2476
- if (mElement && mElement instanceof TransformableElement3 && mElement.isClickable()) {
2473
+ if (mElement && TransformableElement3.isTransformableElement(mElement) && mElement.isClickable()) {
2477
2474
  const elementRelative = getRelativePositionAndRotationRelativeToObject(
2478
2475
  {
2479
2476
  position: intersection.point,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/elements/ThreeJSAudio.ts", "../src/elements/ThreeJSChatProbe.ts", "../src/elements/ThreeJSCube.ts", "../src/elements/ThreeJSCylinder.ts", "../src/elements/ThreeJSDebugHelper.ts", "../src/elements/ThreeJSFrame.ts", "../src/elements/ThreeJSImage.ts", "../src/elements/ThreeJSInteraction.ts", "../src/elements/ThreeJSLabel.ts", "../src/elements/ThreeJSLight.ts", "../src/elements/ThreeJSLink.ts", "../src/elements/ThreeJSMElement.ts", "../src/elements/ThreeJSModel.ts", "../src/elements/ThreeJSPlane.ts", "../src/elements/ThreeJSPositionProbe.ts", "../src/elements/ThreeJSPrompt.ts", "../src/elements/ThreeJSRemoteDocument.ts", "../src/ThreeJSReconnectingStatus.ts", "../src/elements/ThreeJSSphere.ts", "../src/elements/ThreeJSTransformable.ts", "../src/elements/ThreeJSVideo.ts", "../src/ThreeJSClickTrigger.ts", "../src/ThreeJSGraphicsInterface.ts", "../src/ThreeJSInteractionAdapter.ts"],
4
- "sourcesContent": ["import { Audio, MAudioProps } from \"@mml-io/mml-web\";\nimport { AudioGraphics } from \"@mml-io/mml-web\";\nimport { LoadingInstanceManager } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\nimport { PositionalAudioHelper } from \"three/addons/helpers/PositionalAudioHelper.js\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nconst debugAudioSphereSize = 0.25;\nconst debugAudioGeometry = new THREE.SphereGeometry(debugAudioSphereSize, 4, 2);\nconst debugAudioMaterial = new THREE.MeshBasicMaterial({\n wireframe: true,\n fog: false,\n toneMapped: false,\n color: 0x00ff00,\n});\nconst audioRefDistance = 1;\nconst audioRolloffFactor = 1;\n\nfunction extendAudioToDuration(\n context: AudioContext,\n buffer: AudioBuffer,\n seconds: number,\n): AudioBuffer {\n const updatedBuffer = context.createBuffer(\n buffer.numberOfChannels,\n Math.ceil(seconds * buffer.sampleRate),\n buffer.sampleRate,\n );\n for (let channelNumber = 0; channelNumber < buffer.numberOfChannels; channelNumber++) {\n const channelData = buffer.getChannelData(channelNumber);\n const updatedChannelData = updatedBuffer.getChannelData(channelNumber);\n updatedChannelData.set(channelData, 0);\n }\n return updatedBuffer;\n}\n\nexport class ThreeJSAudio extends AudioGraphics<ThreeJSGraphicsAdapter> {\n private audioDebugHelper: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial> | null = null;\n private audioDebugConeX: PositionalAudioHelper | null;\n private audioDebugConeY: PositionalAudioHelper | null;\n private audioContextStateChangedListener = () => {\n this.syncAudioTime();\n };\n\n private documentTimeListener: { remove: () => void };\n private delayedPauseTimer: NodeJS.Timeout | null = null;\n private srcLoadingInstanceManager = new LoadingInstanceManager(`${Audio.tagName}.src`);\n\n private positionalAudio: THREE.PositionalAudio;\n\n private loadedAudioState: {\n loadedAudio:\n | {\n mode: \"LOADED\";\n buffer: AudioBuffer;\n currentSource: {\n sourceNode: AudioBufferSourceNode;\n contextStartTime: number;\n } | null;\n paddedBuffer?: {\n buffer: AudioBuffer;\n totalDuration: number;\n };\n }\n | {\n mode: \"LOADING\";\n srcLoadPromise: Promise<AudioBuffer>;\n abortController: AbortController;\n }\n | null;\n currentSrc: string;\n } | null = null;\n\n constructor(private audio: Audio<ThreeJSGraphicsAdapter>) {\n super(audio);\n\n this.documentTimeListener = this.audio.addDocumentTimeListener(() => {\n if (this.loadedAudioState) {\n this.syncAudioTime();\n }\n });\n\n const audioListener = this.getAudioListener();\n this.positionalAudio = new THREE.PositionalAudio(audioListener);\n this.positionalAudio.context.addEventListener(\n \"statechange\",\n this.audioContextStateChangedListener,\n );\n this.positionalAudio.setVolume(this.audio.props.volume);\n this.positionalAudio.setDirectionalCone(\n this.audio.props.coneFalloffAngle ?? 360,\n this.audio.props.coneAngle,\n 0,\n );\n this.positionalAudio.setRefDistance(audioRefDistance);\n this.positionalAudio.setRolloffFactor(audioRolloffFactor);\n this.audio.getContainer().add(this.positionalAudio);\n\n this.updateAudio();\n this.updateDebugVisualisation();\n }\n\n disable(): void {}\n\n enable(): void {}\n\n public syncAudioTime() {\n const audioContext = this.positionalAudio.context;\n if (audioContext.state !== \"running\") {\n return;\n }\n\n if (this.delayedPauseTimer !== null) {\n clearTimeout(this.delayedPauseTimer);\n this.delayedPauseTimer = null;\n }\n\n if (\n !this.loadedAudioState ||\n !this.loadedAudioState.loadedAudio ||\n this.loadedAudioState.loadedAudio.mode !== \"LOADED\"\n ) {\n return;\n }\n\n const loadedAudio = this.loadedAudioState.loadedAudio;\n const audioBuffer = loadedAudio.buffer;\n let currentSource = loadedAudio.currentSource;\n\n if (!this.audio.props.enabled || this.audio.isDisabled()) {\n if (currentSource) {\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n }\n return;\n }\n\n const documentTime = this.audio.getDocumentTime();\n if (this.audio.props.pauseTime !== null) {\n const timeUntilPause = this.audio.props.pauseTime - documentTime;\n if (timeUntilPause < 2) {\n // The audio should be paused because the pauseTime is in the past or very close\n if (currentSource) {\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n }\n return;\n } else {\n // The pause time is in the future\n const delayedPauseTimer = setTimeout(() => {\n if (this.delayedPauseTimer === delayedPauseTimer) {\n this.delayedPauseTimer = null;\n }\n this.syncAudioTime();\n }, timeUntilPause);\n this.delayedPauseTimer = delayedPauseTimer;\n }\n }\n\n const currentTime = (documentTime - this.audio.props.startTime) / 1000;\n const audioDuration = audioBuffer.duration;\n\n let loopDurationSeconds: number | null = null;\n if (this.audio.props.loopDuration !== null && this.audio.props.loopDuration > 0) {\n loopDurationSeconds = this.audio.props.loopDuration / 1000;\n }\n\n let desiredAudioTime: number;\n if (this.audio.props.loop) {\n if (currentTime < 0) {\n desiredAudioTime = currentTime;\n } else {\n if (loopDurationSeconds === null) {\n desiredAudioTime = currentTime % audioDuration;\n } else {\n desiredAudioTime = currentTime % loopDurationSeconds;\n }\n }\n } else {\n desiredAudioTime = currentTime;\n if (desiredAudioTime > audioDuration) {\n // The audio should stop because it has reached the end\n if (currentSource) {\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n }\n return;\n }\n }\n\n const loopDurationLongerThanAudioDuration =\n loopDurationSeconds && loopDurationSeconds > audioDuration;\n const playbackLength = loopDurationSeconds ? loopDurationSeconds : audioDuration;\n\n if (currentSource) {\n if (currentSource.sourceNode.loop !== this.audio.props.loop) {\n // The loop setting has changed - remove the existing audio source and a new one will be created\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else if (\n loopDurationSeconds !== null &&\n loopDurationLongerThanAudioDuration &&\n (!loadedAudio.paddedBuffer || loadedAudio.paddedBuffer.totalDuration < loopDurationSeconds)\n ) {\n /*\n The loop duration is set, and it is longer than the audio file, and\n either there is no existing padding, or the existing padding is too\n short. Dispose of the existing audio source and create a new one.\n */\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else if (\n loopDurationSeconds === null &&\n currentSource.sourceNode.loopEnd !== audioBuffer.duration\n ) {\n // The loop duration has been removed - reset the loop end to the audio duration\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else {\n if (this.audio.props.startTime > documentTime) {\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else {\n const unloopedCurrentAudioPoint =\n (audioContext.currentTime - currentSource.contextStartTime) /\n currentSource.sourceNode.playbackRate.value;\n\n if (unloopedCurrentAudioPoint < 0) {\n // Audio should not be playing yet, so stop it and it will be rescheduled\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else {\n if (\n loopDurationSeconds !== null &&\n currentSource.sourceNode.loopEnd !== loopDurationSeconds\n ) {\n currentSource.sourceNode.loopEnd = loopDurationSeconds;\n }\n\n const currentAudioPoint = unloopedCurrentAudioPoint % playbackLength;\n\n let delta = desiredAudioTime - currentAudioPoint;\n if (this.audio.props.loop) {\n // Check if the delta wrapping around is smaller (i.e. the desired and current are closer together if we wrap around)\n const loopedDelta = delta - playbackLength;\n if (Math.abs(delta) > Math.abs(loopedDelta)) {\n delta = loopedDelta;\n }\n }\n\n if (Math.abs(delta) > 0.5) {\n // We need to skip to the correct point as playback has drifted too far. Remove the audio source and a new one will be created\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else {\n if (Math.abs(delta) < 0.1) {\n // Do nothing - this is close enough - set the playback rate to 1\n currentSource.sourceNode.playbackRate.value = 1;\n } else {\n if (delta > 0) {\n currentSource.sourceNode.playbackRate.value = 1.01;\n } else {\n currentSource.sourceNode.playbackRate.value = 0.99;\n }\n }\n // Calculate a start time that produces the current time as calculated time the next time it is checked\n currentSource.contextStartTime =\n audioContext.currentTime -\n currentAudioPoint / currentSource.sourceNode.playbackRate.value;\n }\n }\n }\n }\n }\n\n if (!currentSource) {\n // There is no current source (or it was removed) - create a new one\n const currentSourceNode = this.positionalAudio.context.createBufferSource();\n\n let buffer = audioBuffer;\n if (loopDurationSeconds && loopDurationLongerThanAudioDuration) {\n // The loop duration requires longer audio than the original audio - pad it with silence\n if (\n loadedAudio.paddedBuffer &&\n loadedAudio.paddedBuffer.totalDuration === loopDurationSeconds\n ) {\n // The padding is already the correct length\n buffer = loadedAudio.paddedBuffer.buffer;\n } else {\n const paddedBuffer = extendAudioToDuration(\n this.positionalAudio.context,\n audioBuffer,\n loopDurationSeconds,\n );\n loadedAudio.paddedBuffer = {\n buffer: paddedBuffer,\n totalDuration: loopDurationSeconds,\n };\n buffer = paddedBuffer;\n }\n }\n\n currentSourceNode.buffer = buffer;\n currentSourceNode.loop = this.audio.props.loop;\n currentSourceNode.loopStart = 0;\n if (loopDurationSeconds) {\n currentSourceNode.loopEnd = loopDurationSeconds;\n } else {\n currentSourceNode.loopEnd = audioBuffer.duration;\n }\n let contextStartTime;\n if (desiredAudioTime < 0) {\n // The audio should not have started yet - schedule it to start in the future\n const timeFromNowToStart = -desiredAudioTime;\n contextStartTime = audioContext.currentTime + timeFromNowToStart;\n currentSourceNode.start(contextStartTime);\n } else {\n /*\n The audio should have been playing already. Start playing from an\n offset into the file and set the contextStartTime to when it should\n have started\n */\n contextStartTime = audioContext.currentTime - desiredAudioTime;\n currentSourceNode.start(0, desiredAudioTime);\n }\n loadedAudio.currentSource = {\n sourceNode: currentSourceNode,\n contextStartTime,\n };\n this.positionalAudio.setNodeSource(currentSourceNode);\n }\n }\n\n private clearAudio() {\n if (this.loadedAudioState) {\n if (this.loadedAudioState.loadedAudio) {\n if (this.loadedAudioState.loadedAudio.mode === \"LOADING\") {\n this.loadedAudioState.loadedAudio.abortController.abort();\n } else {\n if (this.loadedAudioState.loadedAudio.currentSource?.sourceNode) {\n this.loadedAudioState.loadedAudio.currentSource.sourceNode.stop();\n }\n }\n }\n this.loadedAudioState = null;\n }\n }\n\n private updateAudio() {\n if (!this.audio.isConnected) {\n return;\n }\n\n const audioListener = this.getAudioListener();\n const audioContext = audioListener.context;\n\n if (!this.audio.props.src) {\n this.clearAudio();\n } else {\n const contentAddress = this.audio.contentSrcToContentAddress(this.audio.props.src);\n if (this.loadedAudioState && this.loadedAudioState.currentSrc === contentAddress) {\n // Already loaded this audio src\n } else {\n this.clearAudio();\n\n const abortController = new AbortController();\n\n this.srcLoadingInstanceManager.start(\n this.audio.getLoadingProgressManager(),\n contentAddress,\n );\n const srcLoadPromise = this.asyncLoadSourceAsset(\n contentAddress,\n abortController,\n audioContext,\n (loaded, total) => {\n this.srcLoadingInstanceManager.setProgress(loaded / total);\n },\n );\n this.loadedAudioState = {\n loadedAudio: {\n mode: \"LOADING\",\n abortController,\n srcLoadPromise,\n },\n currentSrc: contentAddress,\n };\n srcLoadPromise\n .then((buffer) => {\n if (\n this.loadedAudioState &&\n this.loadedAudioState.loadedAudio?.mode === \"LOADING\" &&\n this.loadedAudioState.loadedAudio.srcLoadPromise === srcLoadPromise\n ) {\n this.loadedAudioState.loadedAudio = {\n mode: \"LOADED\",\n buffer,\n currentSource: null,\n };\n this.srcLoadingInstanceManager.finish();\n this.syncAudioTime();\n }\n })\n .catch((e) => {\n if (\n this.loadedAudioState &&\n this.loadedAudioState.loadedAudio?.mode === \"LOADING\" &&\n this.loadedAudioState.loadedAudio.srcLoadPromise === srcLoadPromise\n ) {\n console.error(\"Failed to load audio\", e);\n this.srcLoadingInstanceManager.error(e);\n this.clearAudio();\n }\n });\n }\n }\n\n this.syncAudioTime();\n }\n\n async asyncLoadSourceAsset(\n contentAddress: string,\n abortController: AbortController,\n audioContext: AudioContext,\n // TODO - implement progress\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onProgress: (loaded: number, total: number) => void,\n ): Promise<AudioBuffer> {\n return new Promise((resolve, reject) => {\n (async () => {\n if (contentAddress.startsWith(\"data:\")) {\n // Construct an AudioBuffer from the data URL\n const base64 = contentAddress.split(\",\", 2)[1];\n if (!base64) {\n reject(new Error(\"Invalid data URL\"));\n return;\n }\n let arrayBuffer;\n\n try {\n const binary = atob(base64);\n const uint8Array = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n uint8Array[i] = binary.charCodeAt(i);\n }\n arrayBuffer = uint8Array.buffer;\n } catch (e) {\n console.error(\"Failed to decode base64 data URL\", e);\n return;\n }\n audioContext\n .decodeAudioData(arrayBuffer)\n .then((audioBuffer) => {\n if (abortController.signal.aborted) {\n return;\n }\n resolve(audioBuffer);\n })\n .catch((e) => {\n console.error(\"Failed to decode data URI audio data\", e);\n });\n return;\n }\n\n const response = await fetch(contentAddress, {\n signal: abortController.signal,\n });\n\n if (response.ok) {\n response\n .arrayBuffer()\n .then((buffer) => {\n if (abortController.signal.aborted) {\n return;\n }\n audioContext.decodeAudioData(buffer).then((audioBuffer) => {\n if (abortController.signal.aborted) {\n return;\n }\n resolve(audioBuffer);\n });\n })\n .catch((e) => {\n console.error(\"Failed to decode fetched audio data\", e);\n });\n } else {\n console.error(\"Failed to fetch audio data\", response);\n }\n })();\n });\n }\n\n setSrc(): void {\n this.updateAudio();\n }\n setStartTime(): void {\n if (this.loadedAudioState) {\n this.syncAudioTime();\n }\n }\n setPauseTime(): void {\n if (this.loadedAudioState) {\n this.syncAudioTime();\n }\n }\n setLoopDuration(): void {\n if (this.loadedAudioState) {\n this.syncAudioTime();\n }\n }\n setLoop(): void {\n this.updateAudio();\n }\n setEnabled(): void {\n this.updateAudio();\n }\n setVolume(volume: number): void {\n this.positionalAudio.setVolume(volume);\n }\n setConeAngle(coneAngle: number | null, mAudioProps: MAudioProps): void {\n this.positionalAudio.setDirectionalCone(\n mAudioProps.coneAngle,\n mAudioProps.coneFalloffAngle ?? 360,\n 0,\n );\n this.updateDebugVisualisation();\n }\n setConeFalloffAngle(coneFalloffAngle: number | null, mAudioProps: MAudioProps): void {\n this.positionalAudio.setDirectionalCone(\n mAudioProps.coneAngle,\n mAudioProps.coneFalloffAngle ?? 360,\n 0,\n );\n this.updateDebugVisualisation();\n }\n\n setDebug(): void {\n this.updateDebugVisualisation();\n }\n\n dispose() {\n if (this.positionalAudio) {\n this.positionalAudio.context.removeEventListener(\n \"statechange\",\n this.audioContextStateChangedListener,\n );\n this.positionalAudio.disconnect();\n this.positionalAudio.removeFromParent();\n }\n\n this.clearAudio();\n\n if (this.delayedPauseTimer) {\n clearTimeout(this.delayedPauseTimer);\n this.delayedPauseTimer = null;\n }\n this.documentTimeListener.remove();\n this.clearDebugVisualisation();\n this.srcLoadingInstanceManager.dispose();\n }\n\n private clearDebugVisualisation() {\n if (this.audioDebugHelper) {\n this.audioDebugHelper.removeFromParent();\n this.audioDebugHelper = null;\n }\n if (this.audioDebugConeX) {\n this.audioDebugConeX.removeFromParent();\n this.audioDebugConeX = null;\n this.audioDebugConeY?.removeFromParent();\n this.audioDebugConeY = null;\n }\n }\n\n private updateDebugVisualisation() {\n if (!this.audio.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (!this.audioDebugHelper) {\n this.audioDebugHelper = new THREE.Mesh(debugAudioGeometry, debugAudioMaterial);\n this.audio.getContainer().add(this.audioDebugHelper);\n }\n if (!this.audioDebugConeX && this.audio.props.coneAngle) {\n this.audioDebugConeX = new PositionalAudioHelper(this.positionalAudio, 10);\n this.positionalAudio.add(this.audioDebugConeX);\n this.audioDebugConeY = new PositionalAudioHelper(this.positionalAudio, 10);\n this.audioDebugConeY.rotation.z = Math.PI / 2;\n this.positionalAudio.add(this.audioDebugConeY);\n }\n if (!this.audio.props.coneAngle && this.audioDebugConeX) {\n this.audioDebugConeX.removeFromParent();\n this.audioDebugConeX = null;\n this.audioDebugConeY?.removeFromParent();\n this.audioDebugConeY = null;\n }\n }\n this.audioDebugConeX?.update();\n this.audioDebugConeY?.update();\n }\n\n private getAudioListener() {\n return this.audio.getScene().getGraphicsAdapter().getAudioListener();\n }\n}\n", "import { ChatProbe } from \"@mml-io/mml-web\";\nimport { ChatProbeGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSChatProbe extends ChatProbeGraphics<ThreeJSGraphicsAdapter> {\n private static DebugGeometry = new THREE.SphereGeometry(1, 16, 16, 1);\n private static DebugMaterial = new THREE.MeshBasicMaterial({\n color: 0xffff00,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n\n private debugMesh: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial> | null = null;\n\n constructor(private chatProbe: ChatProbe<ThreeJSGraphicsAdapter>) {\n super(chatProbe);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setRange(): void {\n this.updateDebugVisualisation();\n }\n\n setDebug() {\n this.updateDebugVisualisation();\n }\n\n private clearDebugVisualisation() {\n if (this.debugMesh) {\n this.debugMesh.removeFromParent();\n this.debugMesh = null;\n }\n }\n\n private updateDebugVisualisation() {\n if (!this.chatProbe.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (this.chatProbe.isConnected && !this.debugMesh) {\n const mesh = new THREE.Mesh(ThreeJSChatProbe.DebugGeometry, ThreeJSChatProbe.DebugMaterial);\n mesh.castShadow = false;\n mesh.receiveShadow = false;\n this.debugMesh = mesh;\n this.chatProbe.getContainer().add(this.debugMesh);\n }\n\n if (this.debugMesh) {\n this.debugMesh.scale.set(\n this.chatProbe.props.range,\n this.chatProbe.props.range,\n this.chatProbe.props.range,\n );\n }\n }\n }\n\n dispose() {\n this.clearDebugVisualisation();\n }\n}\n", "import { Cube } from \"@mml-io/mml-web\";\nimport { CubeGraphics } from \"@mml-io/mml-web\";\nimport { MMLColor } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSCube extends CubeGraphics<ThreeJSGraphicsAdapter> {\n static boxGeometry = new THREE.BoxGeometry(1, 1, 1);\n private mesh: THREE.Mesh<THREE.BoxGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial;\n constructor(private cube: Cube<ThreeJSGraphicsAdapter>) {\n super(cube);\n\n this.material = new THREE.MeshStandardMaterial({\n color: new THREE.Color(cube.props.color.r, cube.props.color.g, cube.props.color.b),\n });\n this.mesh = new THREE.Mesh(ThreeJSCube.boxGeometry, this.material);\n this.mesh.castShadow = cube.props.castShadows;\n this.mesh.receiveShadow = true;\n this.cube.getContainer().add(this.mesh);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D<THREE.Object3DEventMap> {\n return this.mesh;\n }\n\n setColor(color: MMLColor): void {\n this.material.color = new THREE.Color(color.r, color.g, color.b);\n }\n\n setWidth(width: number): void {\n this.mesh.scale.x = width;\n }\n\n setHeight(height: number): void {\n this.mesh.scale.y = height;\n }\n\n setDepth(depth: number): void {\n this.mesh.scale.z = depth;\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n setOpacity(opacity: number): void {\n const needsUpdate = this.material.transparent === (opacity === 1);\n this.material.transparent = opacity !== 1;\n this.material.needsUpdate = needsUpdate;\n this.material.opacity = opacity;\n }\n\n dispose() {}\n}\n", "import { Cylinder, CylinderGraphics, MMLColor } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSCylinder extends CylinderGraphics<ThreeJSGraphicsAdapter> {\n static cylinderGeometry = new THREE.CylinderGeometry(0.5, 0.5, 1);\n private mesh: THREE.Mesh<THREE.CylinderGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial;\n\n constructor(private cylinder: Cylinder<ThreeJSGraphicsAdapter>) {\n super(cylinder);\n\n this.material = new THREE.MeshStandardMaterial({\n color: new THREE.Color(\n cylinder.props.color.r,\n cylinder.props.color.g,\n cylinder.props.color.b,\n ),\n });\n this.mesh = new THREE.Mesh(ThreeJSCylinder.cylinderGeometry, this.material);\n this.mesh.castShadow = cylinder.props.castShadows;\n this.mesh.receiveShadow = true;\n this.cylinder.getContainer().add(this.mesh);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n setColor(color: MMLColor): void {\n this.material.color = new THREE.Color(color.r, color.g, color.b);\n }\n\n setRadius(radius: number): void {\n this.mesh.scale.x = radius * 2;\n this.mesh.scale.z = radius * 2;\n }\n\n setHeight(height: number): void {\n this.mesh.scale.y = height;\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n setOpacity(opacity: number): void {\n const needsUpdate = this.material.transparent === (opacity === 1);\n this.material.transparent = opacity !== 1;\n this.material.needsUpdate = needsUpdate;\n this.material.opacity = opacity;\n }\n\n dispose() {}\n}\n", "import { DebugHelper, DebugHelperGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSDebugHelper extends DebugHelperGraphics<ThreeJSGraphicsAdapter> {\n private debugAxes: THREE.AxesHelper | null = null;\n\n constructor(private debugHelper: DebugHelper<ThreeJSGraphicsAdapter>) {\n super(debugHelper);\n this.debugAxes = new THREE.AxesHelper(1);\n this.debugHelper.getContainer().add(this.debugAxes);\n }\n\n dispose() {\n if (this.debugAxes) {\n this.debugHelper.getContainer().remove(this.debugAxes);\n }\n this.debugAxes = null;\n }\n}\n", "import { Frame } from \"@mml-io/mml-web\";\nimport { FrameGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nfunction setMeshToBoundingBox(\n mesh: THREE.Mesh,\n minX: number,\n maxX: number,\n minY: number,\n maxY: number,\n minZ: number,\n maxZ: number,\n) {\n mesh.scale.set(maxX - minX, maxY - minY, maxZ - minZ);\n mesh.position.set((maxX + minX) / 2, (maxY + minY) / 2, (maxZ + minZ) / 2);\n}\n\nexport class ThreeJSFrame extends FrameGraphics<ThreeJSGraphicsAdapter> {\n private static DebugBoxGeometry = new THREE.BoxGeometry(1, 1, 1, 1, 1, 1);\n private static DebugConstraintMaterial = new THREE.MeshBasicMaterial({\n color: 0xff0000,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n private static DebugLoadRangeMaterial = new THREE.MeshBasicMaterial({\n color: 0x00ff00,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n private static DebugUnloadRangeMaterial = new THREE.MeshBasicMaterial({\n color: 0x0000ff,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n\n private debugMeshes: {\n debugBoxConstraintMesh: THREE.Mesh<THREE.BoxGeometry, THREE.MeshBasicMaterial>;\n debugBoxLoadRangeMesh: THREE.Mesh<THREE.BoxGeometry, THREE.MeshBasicMaterial>;\n debugBoxUnloadRangeMesh: THREE.Mesh<THREE.BoxGeometry, THREE.MeshBasicMaterial>;\n } | null = null;\n\n constructor(private frame: Frame<ThreeJSGraphicsAdapter>) {\n super(frame);\n }\n\n setSrc() {\n // no-op\n }\n\n setDebug(): void {\n this.updateDebugVisualisation();\n }\n setLoadRange(): void {\n this.updateDebugVisualisation();\n }\n setUnloadRange(): void {\n this.updateDebugVisualisation();\n }\n setMinX(): void {\n this.updateDebugVisualisation();\n }\n setMaxX(): void {\n this.updateDebugVisualisation();\n }\n setMinY(): void {\n this.updateDebugVisualisation();\n }\n setMaxY(): void {\n this.updateDebugVisualisation();\n }\n setMinZ(): void {\n this.updateDebugVisualisation();\n }\n setMaxZ(): void {\n this.updateDebugVisualisation();\n }\n\n disable(): void {}\n\n enable(): void {}\n\n dispose() {}\n\n private clearDebugVisualisation() {\n if (this.debugMeshes) {\n this.debugMeshes.debugBoxConstraintMesh.removeFromParent();\n this.debugMeshes.debugBoxLoadRangeMesh.removeFromParent();\n this.debugMeshes.debugBoxUnloadRangeMesh.removeFromParent();\n this.debugMeshes = null;\n }\n }\n\n private updateDebugVisualisation() {\n if (!this.frame.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (!this.frame.isConnected) {\n return;\n }\n if (!this.debugMeshes) {\n this.debugMeshes = {\n debugBoxConstraintMesh: new THREE.Mesh(\n ThreeJSFrame.DebugBoxGeometry,\n ThreeJSFrame.DebugConstraintMaterial,\n ),\n debugBoxLoadRangeMesh: new THREE.Mesh(\n ThreeJSFrame.DebugBoxGeometry,\n ThreeJSFrame.DebugLoadRangeMaterial,\n ),\n debugBoxUnloadRangeMesh: new THREE.Mesh(\n ThreeJSFrame.DebugBoxGeometry,\n ThreeJSFrame.DebugUnloadRangeMaterial,\n ),\n };\n this.frame.getContainer().add(this.debugMeshes.debugBoxConstraintMesh);\n this.frame.getContainer().add(this.debugMeshes.debugBoxLoadRangeMesh);\n this.frame.getContainer().add(this.debugMeshes.debugBoxUnloadRangeMesh);\n }\n\n let boxBounds = this.frame.getDefinedBoxBounds();\n if (!boxBounds) {\n boxBounds = [0, 0, 0, 0, 0, 0];\n }\n\n const [minX, maxX, minY, maxY, minZ, maxZ] = boxBounds;\n this.debugMeshes.debugBoxConstraintMesh.visible = true;\n this.debugMeshes.debugBoxLoadRangeMesh.visible = true;\n this.debugMeshes.debugBoxUnloadRangeMesh.visible = true;\n\n setMeshToBoundingBox(\n this.debugMeshes.debugBoxConstraintMesh,\n minX,\n maxX,\n minY,\n maxY,\n minZ,\n maxZ,\n );\n\n if (this.frame.props.loadRange === null) {\n this.debugMeshes.debugBoxLoadRangeMesh.visible = false;\n this.debugMeshes.debugBoxUnloadRangeMesh.visible = false;\n } else {\n this.debugMeshes.debugBoxLoadRangeMesh.visible = true;\n this.debugMeshes.debugBoxUnloadRangeMesh.visible = true;\n\n setMeshToBoundingBox(\n this.debugMeshes.debugBoxLoadRangeMesh,\n minX - this.frame.props.loadRange,\n maxX + this.frame.props.loadRange,\n minY - this.frame.props.loadRange,\n maxY + this.frame.props.loadRange,\n minZ - this.frame.props.loadRange,\n maxZ + this.frame.props.loadRange,\n );\n\n setMeshToBoundingBox(\n this.debugMeshes.debugBoxUnloadRangeMesh,\n minX - this.frame.props.loadRange - this.frame.props.unloadRange,\n maxX + this.frame.props.loadRange + this.frame.props.unloadRange,\n minY - this.frame.props.loadRange - this.frame.props.unloadRange,\n maxY + this.frame.props.loadRange + this.frame.props.unloadRange,\n minZ - this.frame.props.loadRange - this.frame.props.unloadRange,\n maxZ + this.frame.props.loadRange + this.frame.props.unloadRange,\n );\n }\n }\n }\n}\n", "import {\n calculateContentSize,\n Image,\n ImageGraphics,\n LoadingInstanceManager,\n} from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSImage extends ImageGraphics<ThreeJSGraphicsAdapter> {\n private static planeGeometry = new THREE.PlaneGeometry(1, 1);\n private mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial;\n private static imageLoader = new THREE.ImageLoader();\n\n private srcApplyPromise: Promise<HTMLImageElement> | null = null;\n private loadedImage: HTMLImageElement | null;\n private loadedImageHasTransparency = false;\n private srcLoadingInstanceManager = new LoadingInstanceManager(`${Image.tagName}.src`);\n constructor(\n private image: Image<ThreeJSGraphicsAdapter>,\n private updateMeshCallback: () => void,\n ) {\n super(image, updateMeshCallback);\n\n this.material = new THREE.MeshStandardMaterial({\n color: 0xffffff,\n transparent: this.image.props.opacity !== 1 || this.loadedImageHasTransparency,\n opacity: this.image.props.opacity,\n side: THREE.DoubleSide,\n });\n this.mesh = new THREE.Mesh(ThreeJSImage.planeGeometry, this.material);\n this.mesh.castShadow = image.props.castShadows;\n this.mesh.receiveShadow = true;\n this.image.getContainer().add(this.mesh);\n }\n\n public getWidthAndHeight(): { width: number; height: number } {\n return {\n width: this.mesh.scale.x,\n height: this.mesh.scale.y,\n };\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n setWidth(): void {\n this.updateWidthAndHeight();\n }\n\n setHeight(): void {\n this.updateWidthAndHeight();\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n setOpacity(opacity: number): void {\n const needsUpdate = this.material.transparent === (opacity === 1);\n this.material.transparent = opacity !== 1;\n this.material.needsUpdate = needsUpdate;\n this.material.opacity = opacity;\n }\n\n setEmissive() {\n this.updateMaterialEmissiveIntensity();\n }\n\n private updateMaterialEmissiveIntensity() {\n if (this.material) {\n const map = this.material.map as THREE.Texture;\n if (this.image.props.emissive > 0) {\n this.material.emissive = new THREE.Color(0xffffff);\n this.material.emissiveMap = map;\n this.material.emissiveIntensity = this.image.props.emissive;\n this.material.needsUpdate = true;\n } else {\n this.material.emissive = new THREE.Color(0x000000);\n this.material.emissiveMap = null;\n this.material.emissiveIntensity = 1;\n this.material.needsUpdate = true;\n }\n }\n }\n\n setSrc(newValue: string | null): void {\n const src = (newValue || \"\").trim();\n const isDataUri = src.startsWith(\"data:image/\");\n if (this.loadedImage !== null && !isDataUri) {\n // if the image has already been loaded, remove the image data from the THREE material\n this.clearImage();\n }\n if (!src) {\n // if the src attribute is empty, reset the dimensions and return\n this.updateWidthAndHeight();\n this.srcLoadingInstanceManager.abortIfLoading();\n return;\n }\n if (!this.material) {\n // if the element is not yet connected, return\n return;\n }\n\n if (isDataUri) {\n // if the src is a data url, load it directly rather than using the loader - this avoids a potential frame skip\n const image = document.createElement(\"img\");\n image.src = src;\n this.applyImage(image);\n this.srcLoadingInstanceManager.abortIfLoading();\n return;\n }\n\n const contentSrc = this.image.contentSrcToContentAddress(src);\n const srcApplyPromise = loadImageAsPromise(\n ThreeJSImage.imageLoader,\n contentSrc,\n (loaded, total) => {\n this.srcLoadingInstanceManager.setProgress(loaded / total);\n },\n );\n this.srcLoadingInstanceManager.start(this.image.getLoadingProgressManager(), contentSrc);\n this.srcApplyPromise = srcApplyPromise;\n srcApplyPromise\n .then((image: HTMLImageElement) => {\n if (this.srcApplyPromise !== srcApplyPromise || !this.material) {\n // If we've loaded a different image since, or we're no longer connected, ignore this image\n return;\n }\n this.applyImage(image);\n this.srcLoadingInstanceManager.finish();\n })\n .catch((error) => {\n console.error(\"Error loading image:\", newValue, error);\n if (this.srcApplyPromise !== srcApplyPromise || !this.material) {\n // If we've loaded a different image since, or we're no longer connected, ignore this image\n return;\n }\n this.clearImage();\n this.srcLoadingInstanceManager.error(error);\n });\n }\n\n private updateWidthAndHeight() {\n const mesh = this.mesh;\n\n const { width, height } = calculateContentSize({\n content: this.loadedImage\n ? { width: this.loadedImage.width, height: this.loadedImage.height }\n : undefined,\n width: this.image.props.width,\n height: this.image.props.height,\n });\n mesh.scale.x = width;\n mesh.scale.y = height;\n\n this.updateMeshCallback();\n }\n\n private applyImage(image: HTMLImageElement) {\n this.loadedImage = image;\n if (!image.complete) {\n // Wait for the image to be fully loaded (most likely a data uri that has not yet been decoded)\n image.addEventListener(\"load\", () => {\n if (this.loadedImage !== image) {\n // if the image has changed since we started loading, ignore this image\n return;\n }\n this.applyImage(image);\n });\n return;\n }\n this.loadedImageHasTransparency = hasTransparency(this.loadedImage);\n if (!this.material) {\n return;\n }\n if (this.loadedImageHasTransparency) {\n this.material.alphaMap = new THREE.CanvasTexture(this.loadedImage);\n this.material.alphaTest = 0.01;\n } else {\n this.material.alphaMap = null;\n this.material.alphaTest = 0;\n }\n this.material.transparent = this.image.props.opacity !== 1 || this.loadedImageHasTransparency;\n this.material.map = new THREE.CanvasTexture(this.loadedImage);\n this.material.needsUpdate = true;\n this.updateMaterialEmissiveIntensity();\n this.updateWidthAndHeight();\n }\n\n private clearImage() {\n this.loadedImage = null;\n this.srcApplyPromise = null;\n if (this.material && this.material.map) {\n this.material.map.dispose();\n this.material.needsUpdate = true;\n this.material.map = null;\n this.material.alphaMap = null;\n this.material.alphaTest = 0;\n }\n this.updateWidthAndHeight();\n }\n\n dispose() {\n if (this.material.map) {\n this.material.map.dispose();\n this.material.map = null;\n }\n if (this.material.emissiveMap) {\n this.material.emissiveMap.dispose();\n this.material.emissiveMap = null;\n }\n this.material.dispose();\n this.loadedImage = null;\n this.srcLoadingInstanceManager.dispose();\n }\n}\n\nexport function loadImageAsPromise(\n imageLoader: THREE.ImageLoader,\n path: string,\n onProgress?: (loaded: number, total: number) => void,\n): Promise<HTMLImageElement> {\n return new Promise<HTMLImageElement>((resolve, reject) => {\n imageLoader.load(\n path,\n (image: HTMLImageElement) => {\n resolve(image);\n },\n (xhr: ProgressEvent) => {\n if (onProgress) {\n onProgress(xhr.loaded, xhr.total);\n }\n },\n (error: ErrorEvent) => {\n reject(error);\n },\n );\n });\n}\n\nfunction hasTransparency(image: HTMLImageElement) {\n if (image.width === 0 || image.height === 0) {\n return false;\n }\n const canvas = document.createElement(\"canvas\");\n canvas.width = image.width;\n canvas.height = image.height;\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D;\n ctx.drawImage(image, 0, 0);\n\n const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;\n\n for (let i = 3, n = imageData.length; i < n; i += 4) {\n if (imageData[i] < 255) {\n return true;\n }\n }\n return false;\n}\n", "import { Interaction } from \"@mml-io/mml-web\";\nimport { InteractionGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSInteraction extends InteractionGraphics<ThreeJSGraphicsAdapter> {\n private static DebugGeometry = new THREE.SphereGeometry(1, 16, 16, 1);\n private static DebugMaterial = new THREE.MeshBasicMaterial({\n color: 0x00aa00,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n\n private debugMesh: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial> | null = null;\n\n constructor(private positionProbe: Interaction<ThreeJSGraphicsAdapter>) {\n super(positionProbe);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setRange(): void {\n this.updateDebugVisualisation();\n }\n\n setInFocus(): void {\n // no-op\n }\n\n setLineOfSight(): void {\n // no-op\n }\n\n setPriority(): void {\n // no-op\n }\n\n setPrompt(): void {\n // no-op\n }\n\n setDebug() {\n this.updateDebugVisualisation();\n }\n\n private clearDebugVisualisation() {\n if (this.debugMesh) {\n this.debugMesh.removeFromParent();\n this.debugMesh = null;\n }\n }\n\n private updateDebugVisualisation() {\n if (!this.positionProbe.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (this.positionProbe.isConnected && !this.debugMesh) {\n const mesh = new THREE.Mesh(\n ThreeJSInteraction.DebugGeometry,\n ThreeJSInteraction.DebugMaterial,\n );\n mesh.castShadow = false;\n mesh.receiveShadow = false;\n this.debugMesh = mesh;\n this.positionProbe.getContainer().add(this.debugMesh);\n }\n\n if (this.debugMesh) {\n this.debugMesh.scale.set(\n this.positionProbe.props.range,\n this.positionProbe.props.range,\n this.positionProbe.props.range,\n );\n }\n }\n }\n\n dispose() {\n this.clearDebugVisualisation();\n }\n}\n", "import { CanvasText, Label, LabelGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSLabel extends LabelGraphics<ThreeJSGraphicsAdapter> {\n static labelGeometry = new THREE.PlaneGeometry(1, 1);\n private mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial | null = null;\n private canvasText: CanvasText = new CanvasText();\n\n constructor(private label: Label<ThreeJSGraphicsAdapter>) {\n super(label);\n\n this.material = new THREE.MeshStandardMaterial({\n transparent: false,\n });\n this.mesh = new THREE.Mesh(ThreeJSLabel.labelGeometry, this.material);\n this.mesh.material = this.material;\n this.mesh.scale.x = this.label.props.width;\n this.mesh.scale.y = this.label.props.height;\n this.mesh.castShadow = this.label.props.castShadows;\n this.mesh.receiveShadow = true;\n this.redrawText();\n this.label.getContainer().add(this.mesh);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n setContent(): void {\n this.redrawText();\n }\n\n setAlignment(): void {\n this.redrawText();\n }\n\n setFontSize(): void {\n this.redrawText();\n }\n\n setPadding(): void {\n this.redrawText();\n }\n\n setFontColor(): void {\n this.redrawText();\n }\n\n setEmissive(): void {\n this.updateMaterialEmissiveIntensity();\n }\n\n setColor(): void {\n this.redrawText();\n }\n\n setWidth(width: number): void {\n this.mesh.scale.x = width;\n this.redrawText();\n }\n\n setHeight(height: number): void {\n this.mesh.scale.y = height;\n this.redrawText();\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n private redrawText() {\n if (!this.material) {\n return;\n }\n if (this.material.map) {\n this.material.map.dispose();\n }\n\n const canvas = this.canvasText.renderText(this.label.props.content, {\n bold: true,\n fontSize: this.label.props.fontSize * 2,\n paddingPx: this.label.props.padding,\n textColorRGB255A1: {\n r: this.label.props.fontColor.r * 255,\n g: this.label.props.fontColor.g * 255,\n b: this.label.props.fontColor.b * 255,\n a: this.label.props.fontColor.a ?? 1,\n },\n backgroundColorRGB255A1: {\n r: this.label.props.color.r * 255,\n g: this.label.props.color.g * 255,\n b: this.label.props.color.b * 255,\n a: this.label.props.color.a ?? 1,\n },\n dimensions: {\n width: this.label.props.width * 200,\n height: this.label.props.height * 200,\n },\n alignment: this.label.props.alignment,\n });\n\n this.material.map = new THREE.CanvasTexture(canvas);\n this.material.transparent = (this.label.props.color.a ?? 1) < 1;\n this.updateMaterialEmissiveIntensity();\n }\n\n private updateMaterialEmissiveIntensity() {\n if (this.material) {\n const map = this.material.map as THREE.Texture;\n if (this.label.props.emissive > 0) {\n this.material.emissive = new THREE.Color(0xffffff);\n this.material.emissiveMap = map;\n this.material.emissiveIntensity = this.label.props.emissive;\n this.material.needsUpdate = true;\n } else {\n this.material.emissive = new THREE.Color(0x000000);\n this.material.emissiveMap = null;\n this.material.emissiveIntensity = 1;\n this.material.needsUpdate = true;\n }\n }\n }\n\n dispose() {\n this.mesh.geometry.dispose();\n if (this.material) {\n if (this.material.map) {\n this.material.map.dispose();\n }\n this.material.dispose();\n this.material = null;\n }\n }\n}\n", "import { Light, LightTypes } from \"@mml-io/mml-web\";\nimport { LightGraphics } from \"@mml-io/mml-web\";\nimport { MMLColor } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\ndeclare type LightHelper = THREE.PointLightHelper | THREE.SpotLightHelper;\n\nconst debugSphereSize = 0.25;\n\nexport class ThreeJSLight extends LightGraphics<ThreeJSGraphicsAdapter> {\n private threeLight: THREE.PointLight | THREE.SpotLight;\n private threeLightHelper: LightHelper | null;\n\n constructor(private light: Light<ThreeJSGraphicsAdapter>) {\n super(light);\n this.createLight();\n }\n\n private createLight() {\n if (this.threeLight) {\n this.threeLight.removeFromParent();\n }\n\n const { r, g, b } = this.light.props.color;\n const color = new THREE.Color(r, g, b);\n\n switch (this.light.props.type) {\n case LightTypes.spotlight: {\n const light = new THREE.SpotLight(\n color,\n this.light.props.intensity,\n this.light.props.distance ?? undefined,\n THREE.MathUtils.degToRad(this.light.props.angleDeg),\n );\n // create a target\n const target = new THREE.Object3D();\n target.position.set(0, -1, 0);\n light.position.set(0, 0, 0);\n light.add(target);\n light.target = target;\n this.threeLight = light;\n break;\n }\n case LightTypes.point:\n this.threeLight = new THREE.PointLight(\n color,\n this.light.props.intensity,\n this.light.props.distance ?? undefined,\n );\n break;\n }\n\n if (this.threeLight.shadow) {\n this.threeLight.castShadow = this.light.props.castShadows;\n this.threeLight.shadow.mapSize.width = 512;\n this.threeLight.shadow.mapSize.height = 512;\n if (this.threeLight.shadow.camera instanceof THREE.PerspectiveCamera) {\n this.threeLight.shadow.camera.near = 0.5;\n this.threeLight.shadow.camera.far = 500;\n }\n this.threeLight.shadow.bias = -0.001;\n this.threeLight.shadow.normalBias = 0.01;\n const d = 10;\n const c = this.threeLight.shadow.camera as any;\n c.left = -d;\n c.right = d;\n c.top = d;\n c.bottom = -d;\n }\n\n this.threeLight.intensity = this.light.props.intensity;\n\n this.light.getContainer().add(this.threeLight);\n\n if (this.threeLightHelper) {\n this.makeLightHelper();\n }\n if (!this.light.props.enabled) {\n this.threeLight.visible = false;\n if (this.threeLightHelper) {\n this.threeLightHelper.visible = false;\n }\n }\n }\n\n private makeLightHelper() {\n if (this.threeLightHelper) {\n this.threeLightHelper.removeFromParent();\n this.threeLightHelper = null;\n }\n\n if (this.light instanceof THREE.PointLight) {\n this.threeLightHelper = new THREE.PointLightHelper(this.light, debugSphereSize);\n } else if (this.light instanceof THREE.SpotLight) {\n this.threeLightHelper = new THREE.SpotLightHelper(this.light);\n }\n\n if (this.threeLightHelper) {\n this.light.getContainer().add(this.threeLightHelper);\n this.threeLightHelper.matrix = this.threeLight.matrix;\n this.threeLightHelper.visible = this.threeLight.visible;\n }\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setEnabled(enabled: boolean): void {\n this.threeLight.visible = enabled;\n if (this.threeLightHelper) {\n this.threeLightHelper.visible = enabled;\n }\n }\n\n setCastShadows(castShadows: boolean) {\n this.threeLight.castShadow = castShadows;\n }\n\n setAngle(angle: number) {\n if (this.threeLight instanceof THREE.SpotLight) {\n (this.threeLight as THREE.SpotLight).angle = THREE.MathUtils.degToRad(angle);\n }\n }\n\n setIntensity(intensity: number) {\n this.threeLight.intensity = intensity;\n }\n\n setDistance(distance: number) {\n this.threeLight.distance = distance;\n }\n\n setType(): void {\n this.createLight();\n }\n\n setDebug(debug: boolean): void {\n if (debug && !this.threeLightHelper) {\n this.makeLightHelper();\n } else if (!debug && this.threeLightHelper) {\n this.threeLightHelper.removeFromParent();\n this.threeLightHelper = null;\n }\n }\n\n setColor(color: MMLColor): void {\n this.threeLight.color.set(new THREE.Color(color.r, color.g, color.b));\n if (this.threeLightHelper) {\n this.threeLightHelper.color = new THREE.Color(color.r, color.g, color.b);\n }\n }\n\n dispose() {\n this.light.getContainer().remove(this.threeLight);\n if (this.threeLightHelper) {\n this.threeLightHelper.removeFromParent();\n }\n }\n}\n", "import { Link } from \"@mml-io/mml-web\";\nimport { LinkGraphics } from \"@mml-io/mml-web\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSLink extends LinkGraphics<ThreeJSGraphicsAdapter> {\n constructor(private link: Link<ThreeJSGraphicsAdapter>) {\n super(link);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setHref(): void {\n // no-op\n }\n\n setTarget(): void {\n // no-op\n }\n\n dispose() {}\n}\n", "import { MElement, MELEMENT_PROPERTY_NAME } from \"@mml-io/mml-web\";\nimport { MElementGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSMElement extends MElementGraphics<ThreeJSGraphicsAdapter> {\n protected container: THREE.Object3D;\n private currentParentContainer: THREE.Object3D | null = null;\n\n constructor(private element: MElement<ThreeJSGraphicsAdapter>) {\n super(element);\n this.container = new THREE.Group();\n this.container.name = this.constructor.name;\n (this.container as any)[MELEMENT_PROPERTY_NAME] = element;\n\n if (this.currentParentContainer !== null) {\n throw new Error(\"Already connected to a parent\");\n }\n\n const mElementParent = this.element.getMElementParent();\n if (mElementParent) {\n this.currentParentContainer = mElementParent.getContainer();\n this.currentParentContainer.add(this.container);\n return;\n }\n\n // If none of the ancestors are MElements then this element may be directly connected to the body (without a wrapper).\n // Attempt to use a global scene that has been configured to attach this element to.\n const scene = this.element.getScene();\n this.currentParentContainer = scene.getGraphicsAdapter().getRootContainer();\n this.currentParentContainer.add(this.container);\n }\n\n public getContainer(): THREE.Object3D {\n return this.container;\n }\n\n public dispose() {\n if (this.currentParentContainer === null) {\n throw new Error(\"Was not connected to a parent\");\n }\n\n this.currentParentContainer.remove(this.container);\n this.currentParentContainer = null;\n }\n}\n", "import { MElement, Model, TransformableElement } from \"@mml-io/mml-web\";\nimport { ModelGraphics } from \"@mml-io/mml-web\";\nimport { LoadingInstanceManager } from \"@mml-io/mml-web\";\nimport { IVect3 } from \"@mml-io/mml-web\";\nimport { ModelLoader, ModelLoadResult } from \"@mml-io/model-loader\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\ntype ThreeJSModelLoadState = {\n group: THREE.Object3D;\n bones: Map<string, THREE.Bone>;\n boundingBox: {\n size: THREE.Vector3;\n centerOffset: THREE.Vector3;\n };\n};\n\ntype ThreeJSModelAnimState = {\n currentAnimationClip: THREE.AnimationClip;\n appliedAnimation: {\n animationGroup: THREE.AnimationObjectGroup;\n animationMixer: THREE.AnimationMixer;\n animationAction: THREE.AnimationAction;\n } | null;\n};\n\nexport class ThreeJSModel extends ModelGraphics<ThreeJSGraphicsAdapter> {\n private static modelLoader = new ModelLoader();\n private srcLoadingInstanceManager = new LoadingInstanceManager(`${Model.tagName}.src`);\n private animLoadingInstanceManager = new LoadingInstanceManager(`${Model.tagName}.anim`);\n private latestSrcModelPromise: Promise<ModelLoadResult> | null = null;\n private latestAnimPromise: Promise<ModelLoadResult> | null = null;\n\n private socketChildrenByBone = new Map<string, Set<MElement<ThreeJSGraphicsAdapter>>>();\n\n private attachments = new Map<\n Model<ThreeJSGraphicsAdapter>,\n {\n animationGroup: THREE.AnimationObjectGroup;\n animationMixer: THREE.AnimationMixer;\n animationAction: THREE.AnimationAction;\n } | null\n >();\n private registeredParentAttachment: Model<ThreeJSGraphicsAdapter> | null = null;\n\n private static DebugBoundingBoxGeometry = new THREE.BoxGeometry(1, 1, 1, 1, 1, 1);\n private static DebugBoundingBoxMaterial = new THREE.MeshBasicMaterial({\n color: 0xff0000,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n private debugBoundingBox: THREE.Mesh | null = null;\n\n protected loadedState: ThreeJSModelLoadState | null = null;\n protected animState: ThreeJSModelAnimState | null = null;\n\n private documentTimeTickListener: null | { remove: () => void } = null;\n\n constructor(\n private model: Model<ThreeJSGraphicsAdapter>,\n private updateMeshCallback: () => void,\n ) {\n super(model, updateMeshCallback);\n }\n\n hasLoadedModel(): boolean {\n return !!this.loadedState?.group;\n }\n\n hasLoadedAnimation(): boolean {\n return !!this.animState?.appliedAnimation;\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getBoundingBox(): { centerOffset: IVect3; size: IVect3 } | null {\n if (this.loadedState) {\n return {\n centerOffset: this.loadedState.boundingBox.centerOffset,\n size: this.loadedState.boundingBox.size,\n };\n }\n return null;\n }\n\n getCollisionElement(): THREE.Object3D<THREE.Object3DEventMap> {\n return this.loadedState?.group ?? new THREE.Object3D();\n }\n\n setDebug(): void {\n this.updateDebugVisualisation();\n }\n\n setCastShadows(castShadows: boolean) {\n if (this.loadedState) {\n this.loadedState.group.traverse((object) => {\n if ((object as THREE.Mesh).isMesh) {\n const mesh = object as THREE.Mesh;\n mesh.castShadow = castShadows;\n }\n });\n }\n }\n\n setAnim(anim: string): void {\n this.resetAnimationMixer();\n this.animState = null;\n for (const [attachment, animState] of this.attachments) {\n if (animState) {\n animState.animationMixer.stopAllAction();\n this.attachments.set(attachment, null);\n }\n }\n\n if (!anim) {\n this.latestAnimPromise = null;\n this.animLoadingInstanceManager.abortIfLoading();\n\n // If the animation is removed then the model can be added to the parent attachment if the model is loaded\n if (this.loadedState && !this.registeredParentAttachment) {\n const parent = this.model.parentElement;\n if (parent instanceof Model) {\n this.registeredParentAttachment = parent;\n (parent.modelGraphics as ThreeJSModel).registerAttachment(this.model);\n }\n }\n return;\n }\n\n if (this.registeredParentAttachment) {\n (this.registeredParentAttachment.modelGraphics as ThreeJSModel).unregisterAttachment(\n this.model,\n );\n this.registeredParentAttachment = null;\n }\n\n const animSrc = this.model.contentSrcToContentAddress(anim);\n const animPromise = this.asyncLoadSourceAsset(animSrc, (loaded, total) => {\n this.animLoadingInstanceManager.setProgress(loaded / total);\n });\n this.animLoadingInstanceManager.start(this.model.getLoadingProgressManager(), animSrc);\n this.latestAnimPromise = animPromise;\n animPromise\n .then((result) => {\n if (this.latestAnimPromise !== animPromise || !this.model.isConnected) {\n return;\n }\n this.latestAnimPromise = null;\n this.playAnimation(result.animations[0]);\n\n for (const [model] of this.attachments) {\n this.registerAttachment(model);\n }\n\n this.animLoadingInstanceManager.finish();\n })\n .catch((err) => {\n console.error(\"Error loading m-model.anim\", err);\n this.latestAnimPromise = null;\n this.animLoadingInstanceManager.error(err);\n });\n }\n\n setAnimEnabled(): void {\n // no-op - property is observed in animation tick\n }\n\n setAnimLoop(): void {\n // no-op - property is observed in animation tick\n }\n\n setAnimStartTime(): void {\n // no-op - property is observed in animation tick\n }\n\n setAnimPauseTime(): void {\n // no-op - property is observed in animation tick\n }\n\n transformed(): void {\n // no-op\n }\n\n setSrc(src: string): void {\n if (this.loadedState !== null) {\n this.loadedState.group.removeFromParent();\n if (this.registeredParentAttachment) {\n (this.registeredParentAttachment.modelGraphics as ThreeJSModel).unregisterAttachment(\n this.model,\n );\n this.registeredParentAttachment = null;\n }\n ThreeJSModel.disposeOfGroup(this.loadedState.group);\n this.loadedState = null;\n this.updateMeshCallback();\n this.updateDebugVisualisation();\n }\n if (!src) {\n this.srcLoadingInstanceManager.abortIfLoading();\n this.socketChildrenByBone.forEach((children) => {\n children.forEach((child) => {\n this.model.getContainer().add(child.getContainer());\n });\n });\n this.updateMeshCallback();\n this.updateDebugVisualisation();\n return;\n }\n\n const contentSrc = this.model.contentSrcToContentAddress(src);\n const srcModelPromise = this.asyncLoadSourceAsset(contentSrc, (loaded, total) => {\n this.srcLoadingInstanceManager.setProgress(loaded / total);\n });\n this.srcLoadingInstanceManager.start(this.model.getLoadingProgressManager(), contentSrc);\n this.latestSrcModelPromise = srcModelPromise;\n srcModelPromise\n .then((result) => {\n if (this.latestSrcModelPromise !== srcModelPromise || !this.model.isConnected) {\n // If we've loaded a different model since, or we're no longer connected, dispose of this one\n ThreeJSModel.disposeOfGroup(result.group);\n return;\n }\n result.group.traverse((child) => {\n if ((child as THREE.Mesh).isMesh) {\n child.castShadow = this.model.props.castShadows;\n child.receiveShadow = true;\n }\n });\n this.latestSrcModelPromise = null;\n const group = result.group;\n const bones = new Map<string, THREE.Bone>();\n group.traverse((object) => {\n if (object instanceof THREE.Bone) {\n bones.set(object.name, object);\n }\n });\n const boundingBox = new THREE.Box3();\n group.updateWorldMatrix(true, true);\n boundingBox.expandByObject(group);\n\n this.loadedState = {\n group,\n bones,\n boundingBox: {\n size: boundingBox.getSize(new THREE.Vector3(0, 0, 0)),\n centerOffset: boundingBox.getCenter(new THREE.Vector3(0, 0, 0)),\n },\n };\n this.model.getContainer().add(group);\n\n for (const [boneName, children] of this.socketChildrenByBone) {\n const bone = bones.get(boneName);\n if (bone) {\n children.forEach((child) => {\n bone.add(child.getContainer());\n });\n }\n }\n\n this.updateMeshCallback();\n\n const parent = this.model.parentElement;\n if (parent instanceof Model) {\n if (!this.latestAnimPromise && !this.animState) {\n this.registeredParentAttachment = parent;\n (parent.modelGraphics as ThreeJSModel).registerAttachment(this.model);\n }\n }\n\n if (this.animState) {\n this.playAnimation(this.animState.currentAnimationClip);\n }\n this.srcLoadingInstanceManager.finish();\n\n this.updateDebugVisualisation();\n })\n .catch((err) => {\n console.error(\"Error loading m-model.src\", err);\n this.srcLoadingInstanceManager.error(err);\n });\n }\n\n public registerAttachment(attachment: Model<ThreeJSGraphicsAdapter>) {\n let animState = null;\n if (this.animState) {\n const attachmentLoadedState = (attachment.modelGraphics as ThreeJSModel).loadedState;\n if (!attachmentLoadedState) {\n throw new Error(\"Attachment must be loaded before registering\");\n }\n const animationGroup = new THREE.AnimationObjectGroup();\n const animationMixer = new THREE.AnimationMixer(animationGroup);\n const action = animationMixer.clipAction(this.animState.currentAnimationClip);\n animState = {\n animationGroup,\n animationMixer,\n animationAction: action,\n };\n animationGroup.add(attachmentLoadedState.group);\n action.play();\n }\n this.attachments.set(attachment, animState);\n }\n\n public unregisterAttachment(attachment: Model<ThreeJSGraphicsAdapter>) {\n const attachmentState = this.attachments.get(attachment);\n if (attachmentState) {\n attachmentState.animationMixer.stopAllAction();\n }\n this.attachments.delete(attachment);\n }\n\n private updateDebugVisualisation() {\n if (!this.model.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (!this.debugBoundingBox) {\n this.debugBoundingBox = new THREE.Mesh(\n ThreeJSModel.DebugBoundingBoxGeometry,\n ThreeJSModel.DebugBoundingBoxMaterial,\n );\n this.model.getContainer().add(this.debugBoundingBox);\n }\n if (this.loadedState) {\n const boundingBox = this.loadedState.boundingBox;\n if (boundingBox.centerOffset) {\n this.debugBoundingBox.position.copy(boundingBox.centerOffset);\n } else {\n this.debugBoundingBox.position.set(0, 0, 0);\n }\n this.debugBoundingBox.scale.copy(boundingBox.size);\n } else {\n this.debugBoundingBox.scale.set(0, 0, 0);\n }\n }\n }\n\n private clearDebugVisualisation() {\n if (this.debugBoundingBox) {\n this.debugBoundingBox.removeFromParent();\n this.debugBoundingBox = null;\n }\n }\n\n async asyncLoadSourceAsset(\n url: string,\n onProgress: (loaded: number, total: number) => void,\n ): Promise<ModelLoadResult> {\n return await ThreeJSModel.modelLoader.load(url, onProgress);\n }\n\n private resetAnimationMixer() {\n if (this.documentTimeTickListener) {\n this.documentTimeTickListener.remove();\n this.documentTimeTickListener = null;\n }\n if (this.animState) {\n const appliedAnimation = this.animState.appliedAnimation;\n if (appliedAnimation) {\n appliedAnimation.animationMixer.stopAllAction();\n }\n this.animState.appliedAnimation = null;\n }\n }\n\n public registerSocketChild(\n child: TransformableElement<ThreeJSGraphicsAdapter>,\n socketName: string,\n ): void {\n let children = this.socketChildrenByBone.get(socketName);\n if (!children) {\n children = new Set<MElement<ThreeJSGraphicsAdapter>>();\n this.socketChildrenByBone.set(socketName, children);\n }\n children.add(child);\n\n if (this.loadedState) {\n const bone = this.loadedState.bones.get(socketName);\n if (bone) {\n bone.add(child.getContainer());\n } else {\n this.model.getContainer().add(child.getContainer());\n }\n }\n }\n\n public unregisterSocketChild(\n child: TransformableElement<ThreeJSGraphicsAdapter>,\n socketName: string,\n addToRoot: boolean = true,\n ): void {\n const socketChildren = this.socketChildrenByBone.get(socketName);\n if (socketChildren) {\n socketChildren.delete(child);\n if (addToRoot) {\n this.model.getContainer().add(child.getContainer());\n }\n if (socketChildren.size === 0) {\n this.socketChildrenByBone.delete(socketName);\n }\n }\n }\n\n private triggerSocketedChildrenTransformed() {\n // Socketed children need to be updated when the animation is updated as their position may have updated\n this.socketChildrenByBone.forEach((children) => {\n children.forEach((child) => {\n if (child instanceof TransformableElement) {\n child.didUpdateTransformation();\n }\n });\n });\n }\n\n private playAnimation(anim: THREE.AnimationClip) {\n this.resetAnimationMixer();\n this.animState = {\n currentAnimationClip: anim,\n appliedAnimation: null,\n };\n const animationGroup = new THREE.AnimationObjectGroup();\n const animationMixer = new THREE.AnimationMixer(animationGroup);\n const action = animationMixer.clipAction(anim);\n this.animState.appliedAnimation = {\n animationGroup,\n animationMixer,\n animationAction: action,\n };\n if (this.loadedState) {\n animationGroup.add(this.loadedState.group);\n }\n action.play();\n if (!this.documentTimeTickListener) {\n this.documentTimeTickListener = this.model.addDocumentTimeTickListener(\n (documentTime: number) => {\n this.updateAnimation(documentTime);\n },\n );\n }\n }\n\n private updateAnimation(docTimeMs: number, force: boolean = false) {\n if (this.animState) {\n if (!this.model.props.animEnabled && this.animState.appliedAnimation) {\n this.resetAnimationMixer();\n this.triggerSocketedChildrenTransformed();\n } else {\n if (!this.animState.appliedAnimation) {\n this.playAnimation(this.animState.currentAnimationClip);\n }\n let animationTimeMs = docTimeMs - this.model.props.animStartTime;\n if (docTimeMs < this.model.props.animStartTime) {\n animationTimeMs = 0;\n } else if (this.model.props.animPauseTime !== null) {\n if (docTimeMs > this.model.props.animPauseTime) {\n animationTimeMs = this.model.props.animPauseTime - this.model.props.animStartTime;\n }\n }\n\n const clip = this.animState.currentAnimationClip;\n if (clip !== null) {\n if (!this.model.props.animLoop) {\n if (animationTimeMs > clip.duration * 1000) {\n animationTimeMs = clip.duration * 1000;\n }\n }\n }\n\n for (const [model, attachmentState] of this.attachments) {\n if (attachmentState) {\n attachmentState.animationMixer.setTime(animationTimeMs / 1000);\n (model.modelGraphics as ThreeJSModel).triggerSocketedChildrenTransformed();\n }\n }\n\n if (force) {\n this.animState.appliedAnimation?.animationMixer.setTime((animationTimeMs + 1) / 1000);\n }\n this.animState.appliedAnimation?.animationMixer.setTime(animationTimeMs / 1000);\n this.triggerSocketedChildrenTransformed();\n }\n }\n }\n\n dispose() {\n if (this.documentTimeTickListener) {\n this.documentTimeTickListener.remove();\n this.documentTimeTickListener = null;\n }\n if (this.registeredParentAttachment) {\n (this.registeredParentAttachment?.modelGraphics as ThreeJSModel)?.unregisterAttachment(\n this.model,\n );\n this.registeredParentAttachment = null;\n }\n if (this.loadedState) {\n this.loadedState.group.removeFromParent();\n ThreeJSModel.disposeOfGroup(this.loadedState.group);\n this.loadedState = null;\n }\n this.clearDebugVisualisation();\n this.animLoadingInstanceManager.dispose();\n this.srcLoadingInstanceManager.dispose();\n }\n\n private static disposeOfGroup(group: THREE.Object3D) {\n group.traverse((child) => {\n if ((child as THREE.Mesh).isMesh) {\n const mesh = child as THREE.Mesh;\n mesh.geometry.dispose();\n if (Array.isArray(mesh.material)) {\n for (const material of mesh.material) {\n ThreeJSModel.disposeOfMaterial(material);\n }\n } else if (mesh.material) {\n ThreeJSModel.disposeOfMaterial(mesh.material);\n }\n }\n });\n }\n\n private static disposeOfMaterial(material: THREE.Material) {\n material.dispose();\n for (const key of Object.keys(material)) {\n const value = (material as any)[key];\n if (value && typeof value === \"object\" && \"minFilter\" in value) {\n value.dispose();\n }\n }\n }\n}\n", "import { Plane } from \"@mml-io/mml-web\";\nimport { MMLColor } from \"@mml-io/mml-web\";\nimport { PlaneGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSPlane extends PlaneGraphics<ThreeJSGraphicsAdapter> {\n static planeGeometry = new THREE.PlaneGeometry(1, 1);\n private mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial;\n\n constructor(private plane: Plane<ThreeJSGraphicsAdapter>) {\n super(plane);\n\n this.material = new THREE.MeshStandardMaterial({\n color: new THREE.Color(plane.props.color.r, plane.props.color.g, plane.props.color.b),\n });\n this.mesh = new THREE.Mesh(ThreeJSPlane.planeGeometry, this.material);\n this.mesh.castShadow = plane.props.castShadows;\n this.mesh.receiveShadow = true;\n this.plane.getContainer().add(this.mesh);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n setColor(color: MMLColor): void {\n this.material.color = new THREE.Color(color.r, color.g, color.b);\n }\n\n setWidth(width: number): void {\n this.mesh.scale.x = width;\n }\n\n setHeight(height: number): void {\n this.mesh.scale.y = height;\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n setOpacity(opacity: number): void {\n const needsUpdate = this.material.transparent === (opacity === 1);\n this.material.transparent = opacity !== 1;\n this.material.needsUpdate = needsUpdate;\n this.material.opacity = opacity;\n }\n\n dispose() {}\n}\n", "import { PositionProbe } from \"@mml-io/mml-web\";\nimport { PositionProbeGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSPositionProbe extends PositionProbeGraphics<ThreeJSGraphicsAdapter> {\n private static DebugGeometry = new THREE.SphereGeometry(1, 16, 16, 1);\n private static DebugMaterial = new THREE.MeshBasicMaterial({\n color: 0xff0000,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n\n private debugMesh: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial> | null = null;\n\n constructor(private positionProbe: PositionProbe<ThreeJSGraphicsAdapter>) {\n super(positionProbe);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setRange(): void {\n this.updateDebugVisualisation();\n }\n\n setDebug() {\n this.updateDebugVisualisation();\n }\n\n private clearDebugVisualisation() {\n if (this.debugMesh) {\n this.debugMesh.removeFromParent();\n this.debugMesh = null;\n }\n }\n\n private updateDebugVisualisation() {\n if (!this.positionProbe.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (this.positionProbe.isConnected && !this.debugMesh) {\n const mesh = new THREE.Mesh(\n ThreeJSPositionProbe.DebugGeometry,\n ThreeJSPositionProbe.DebugMaterial,\n );\n mesh.castShadow = false;\n mesh.receiveShadow = false;\n this.debugMesh = mesh;\n this.positionProbe.getContainer().add(this.debugMesh);\n }\n\n if (this.debugMesh) {\n this.debugMesh.scale.set(\n this.positionProbe.props.range,\n this.positionProbe.props.range,\n this.positionProbe.props.range,\n );\n }\n }\n }\n\n dispose() {\n this.clearDebugVisualisation();\n }\n}\n", "import { Prompt } from \"@mml-io/mml-web\";\nimport { PromptGraphics } from \"@mml-io/mml-web\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSPrompt extends PromptGraphics<ThreeJSGraphicsAdapter> {\n constructor(private prompt: Prompt<ThreeJSGraphicsAdapter>) {\n super(prompt);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setMessage(): void {\n // no-op\n }\n\n setPlaceholder(): void {\n // no-op\n }\n\n setPrefill(): void {\n // no-op\n }\n\n setDebug(): void {\n // no-op\n }\n\n dispose() {}\n}\n", "import { RemoteDocument, RemoteDocumentGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\nimport { getThreeJSReconnectingStatus } from \"../ThreeJSReconnectingStatus\";\n\nexport class ThreeJSRemoteDocument extends RemoteDocumentGraphics<ThreeJSGraphicsAdapter> {\n private statusUI: THREE.Mesh | null = null;\n\n constructor(private element: RemoteDocument<ThreeJSGraphicsAdapter>) {\n super(element);\n }\n\n public showError(showError: boolean): void {\n if (!showError) {\n if (this.statusUI !== null) {\n this.element.getContainer().remove(this.statusUI);\n this.statusUI = null;\n }\n } else {\n if (this.statusUI === null) {\n const { geometry, material, height } = getThreeJSReconnectingStatus();\n const mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.MeshBasicMaterial> = new THREE.Mesh(\n geometry,\n material,\n );\n mesh.position.set(0, height / 2, 0);\n this.statusUI = mesh;\n this.element.getContainer().add(this.statusUI);\n }\n }\n }\n\n public dispose() {}\n}\n", "import { CanvasText } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nfunction createReconnectingStatus() {\n const canvas = new CanvasText().renderText(\"Reconnecting\", {\n bold: true,\n fontSize: 32,\n paddingPx: 10,\n textColorRGB255A1: {\n r: 255,\n g: 0,\n b: 0,\n a: 1.0,\n },\n backgroundColorRGB255A1: {\n r: 255,\n g: 255,\n b: 255,\n a: 1.0,\n },\n alignment: \"center\",\n });\n\n const texture = new THREE.Texture(canvas);\n texture.minFilter = THREE.LinearFilter;\n texture.magFilter = THREE.LinearFilter;\n texture.format = THREE.RGBAFormat;\n texture.needsUpdate = true;\n\n const width = canvas.width;\n const height = canvas.height;\n\n const material = new THREE.MeshBasicMaterial({\n map: texture,\n side: THREE.DoubleSide,\n });\n const geometry = new THREE.PlaneGeometry(width / 100, height / 100, 1, 1);\n return { geometry, material, width: width / 100, height: height / 100 };\n}\n\nexport type ThreeJSReconnectingStatus = {\n geometry: THREE.PlaneGeometry;\n material: THREE.MeshBasicMaterial;\n width: number;\n height: number;\n};\n\nlet reconnectingStatus: ThreeJSReconnectingStatus | null = null;\n\nexport function getThreeJSReconnectingStatus(): ThreeJSReconnectingStatus {\n if (!reconnectingStatus) {\n reconnectingStatus = createReconnectingStatus();\n }\n return reconnectingStatus;\n}\n", "import { Sphere } from \"@mml-io/mml-web\";\nimport { MMLColor } from \"@mml-io/mml-web\";\nimport { SphereGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nconst defaultSphereWidthSegments = 16;\nconst defaultSphereHeightSegments = 16;\n\nexport class ThreeJSSphere extends SphereGraphics<ThreeJSGraphicsAdapter> {\n static sphereGeometry = new THREE.SphereGeometry(\n 0.5,\n defaultSphereWidthSegments,\n defaultSphereHeightSegments,\n );\n private mesh: THREE.Mesh<THREE.SphereGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial;\n\n constructor(private sphere: Sphere<ThreeJSGraphicsAdapter>) {\n super(sphere);\n\n this.material = new THREE.MeshStandardMaterial({\n color: new THREE.Color(sphere.props.color.r, sphere.props.color.g, sphere.props.color.b),\n });\n this.mesh = new THREE.Mesh(ThreeJSSphere.sphereGeometry, this.material);\n this.mesh.castShadow = sphere.props.castShadows;\n this.mesh.receiveShadow = true;\n this.sphere.getContainer().add(this.mesh);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n setColor(color: MMLColor): void {\n this.material.color = new THREE.Color(color.r, color.g, color.b);\n }\n\n setRadius(radius: number): void {\n this.mesh.scale.x = radius * 2;\n this.mesh.scale.y = radius * 2;\n this.mesh.scale.z = radius * 2;\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n setOpacity(opacity: number): void {\n const needsUpdate = this.material.transparent === (opacity === 1);\n this.material.transparent = opacity !== 1;\n this.material.needsUpdate = needsUpdate;\n this.material.opacity = opacity;\n }\n\n dispose() {}\n}\n", "import {\n Matr4,\n Matr4Data,\n Model,\n TransformableElement,\n TransformableGraphics,\n} from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\nimport { ThreeJSModel } from \"./ThreeJSModel\";\n\nexport class ThreeJSTransformable extends TransformableGraphics<ThreeJSGraphicsAdapter> {\n private socketName: string | null = null;\n private registeredSocketParent: ThreeJSModel | null = null;\n\n constructor(private transformableElement: TransformableElement<ThreeJSGraphicsAdapter>) {\n super(transformableElement);\n }\n\n getWorldMatrix(): Matr4 {\n // TODO - optimize/reduce calls to updateWorldMatrix\n const container = this.getContainer();\n container.updateWorldMatrix(true, false);\n return new Matr4(container.matrixWorld.elements as Matr4Data);\n }\n\n setVisible(visible: boolean): void {\n this.getContainer().visible = visible;\n }\n\n setSocket(socketName: string | null): void {\n if (this.socketName !== socketName) {\n if (this.socketName !== null && this.registeredSocketParent) {\n this.registeredSocketParent.unregisterSocketChild(\n this.transformableElement,\n this.socketName,\n );\n }\n this.socketName = socketName;\n if (socketName !== null) {\n this.registerWithParentModel(socketName);\n }\n } else {\n this.socketName = socketName;\n }\n }\n\n private registerWithParentModel(socketName: string): void {\n if (\n (this.transformableElement.parentElement as Model<ThreeJSGraphicsAdapter> | undefined)\n ?.isModel\n ) {\n const parentModel = this.transformableElement.parentElement as Model<ThreeJSGraphicsAdapter>;\n this.registeredSocketParent = parentModel.modelGraphics as ThreeJSModel;\n this.registeredSocketParent.registerSocketChild(this.transformableElement, socketName);\n }\n }\n\n private getContainer(): THREE.Group {\n return this.transformableElement.getContainer() as THREE.Group;\n }\n\n setX(x: number): void {\n this.getContainer().position.x = x;\n }\n\n setY(y: number): void {\n this.getContainer().position.y = y;\n }\n\n setZ(z: number): void {\n this.getContainer().position.z = z;\n }\n\n setRotationX(rotationX: number): void {\n this.getContainer().rotation.x = rotationX * THREE.MathUtils.DEG2RAD;\n }\n\n setRotationY(rotationY: number): void {\n this.getContainer().rotation.y = rotationY * THREE.MathUtils.DEG2RAD;\n }\n\n setRotationZ(rotationZ: number): void {\n this.getContainer().rotation.z = rotationZ * THREE.MathUtils.DEG2RAD;\n }\n\n setScaleX(scaleX: number): void {\n this.getContainer().scale.x = scaleX;\n }\n\n setScaleY(scaleY: number): void {\n this.getContainer().scale.y = scaleY;\n }\n\n setScaleZ(scaleZ: number): void {\n this.getContainer().scale.z = scaleZ;\n }\n\n dispose() {\n if (this.socketName && this.registeredSocketParent !== null) {\n this.registeredSocketParent.unregisterSocketChild(\n this.transformableElement,\n this.socketName,\n false,\n );\n }\n }\n}\n", "import {\n calculateContentSize,\n StaticFileVideoSource,\n Video,\n VideoGraphics,\n VideoSource,\n WHEPVideoSource,\n} from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nconst audioRefDistance = 1;\nconst audioRolloffFactor = 1;\n\nconst disabledVideoMaterial = new THREE.MeshStandardMaterial({\n color: 0x000000,\n side: THREE.DoubleSide,\n});\n\nexport class ThreeJSVideo extends VideoGraphics<ThreeJSGraphicsAdapter> {\n private videoSource: VideoSource | null = null;\n private videoMaterial: THREE.MeshStandardMaterial;\n\n private mesh: THREE.Mesh<\n THREE.PlaneGeometry,\n THREE.MeshStandardMaterial | THREE.MeshBasicMaterial\n >;\n\n private loadedVideoState: {\n video: HTMLVideoElement;\n audio: THREE.PositionalAudio;\n videoTexture: THREE.VideoTexture | null;\n } | null = null;\n\n constructor(\n private video: Video<ThreeJSGraphicsAdapter>,\n private updateMeshCallback: () => void,\n ) {\n super(video, updateMeshCallback);\n\n const geometry = new THREE.PlaneGeometry(1, 1, 1, 1);\n // Video material is only applied once a video is played\n this.videoMaterial = new THREE.MeshStandardMaterial({\n color: 0xffffff,\n transparent: false,\n side: THREE.DoubleSide,\n });\n this.mesh = new THREE.Mesh(geometry, disabledVideoMaterial);\n this.mesh.castShadow = true;\n this.mesh.receiveShadow = false;\n this.video.getContainer().add(this.mesh);\n }\n\n public getWidthAndHeight(): { width: number; height: number } {\n return {\n width: this.mesh.scale.x,\n height: this.mesh.scale.y,\n };\n }\n\n public syncVideoTime() {\n if (this.loadedVideoState) {\n const videoTag = this.loadedVideoState.video;\n if (videoTag.readyState === 0) {\n return;\n }\n\n const audioListener = this.getAudioListener();\n const audioContext = audioListener.context;\n if (audioContext.state === \"running\") {\n videoTag.muted = false;\n }\n\n if (this.video.isDisabled()) {\n videoTag.muted = true;\n }\n\n if (this.videoSource) {\n this.videoSource.syncVideoSource(this.video.props);\n }\n }\n }\n\n private getAudioListener() {\n return this.video.getScene().getGraphicsAdapter().getAudioListener();\n }\n\n public enable(): void {\n this.updateVideo();\n }\n public disable(): void {\n this.updateVideo();\n }\n\n public getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n public setSrc(): void {\n this.updateVideo();\n }\n\n public setWidth(): void {\n this.updateWidthAndHeight();\n }\n\n public setHeight(): void {\n this.updateWidthAndHeight();\n }\n\n public setEnabled(): void {\n this.updateVideo();\n }\n\n public setCastShadows(): void {\n this.updateVideo();\n }\n\n public setLoop(): void {\n this.updateVideo();\n }\n\n public setVolume(): void {\n if (this.loadedVideoState) {\n this.loadedVideoState.audio.setVolume(this.video.props.volume);\n }\n }\n\n public setEmissive(): void {\n this.updateVideo();\n this.updateMaterialEmissiveIntensity();\n }\n\n public setStartTime(): void {\n this.updateVideo();\n }\n\n public setPauseTime(): void {\n this.updateVideo();\n }\n\n private updateVideo() {\n if (!this.video.isConnected) {\n return;\n }\n\n if (!this.video.props.enabled) {\n this.clearSource();\n return;\n }\n\n if (!this.video.props.src) {\n this.clearSource();\n } else {\n const contentAddress = this.video.contentSrcToContentAddress(this.video.props.src);\n if (this.videoSource === null || this.videoSource.getContentAddress() !== contentAddress) {\n this.clearSource();\n\n const video = document.createElement(\"video\");\n video.playsInline = true;\n // Muted allows autoplay immediately without the user needing to interact with the document\n // Video will be unmuted when the audiocontext is available\n video.muted = true;\n video.autoplay = true;\n video.crossOrigin = \"anonymous\";\n\n const audioListener = this.getAudioListener();\n const audioContext = audioListener.context;\n\n const audio = new THREE.PositionalAudio(audioListener);\n audio.setMediaElementSource(video);\n audio.setVolume(this.video.props.volume);\n audio.setRefDistance(audioRefDistance);\n audio.setRolloffFactor(audioRolloffFactor);\n this.loadedVideoState = {\n video,\n audio,\n videoTexture: null,\n };\n this.updateMaterialEmissiveIntensity();\n this.video.getContainer().add(audio);\n\n const url = new URL(contentAddress);\n if (WHEPVideoSource.isWHEPURL(url)) {\n this.videoSource = new WHEPVideoSource(url, video);\n } else {\n this.videoSource = new StaticFileVideoSource(url, video, this.video.props, () => {\n return this.video.getDocumentTime();\n });\n }\n\n audioContext.addEventListener(\"statechange\", () => {\n this.syncVideoTime();\n });\n video.addEventListener(\"loadeddata\", () => {\n if (!this.loadedVideoState || this.loadedVideoState.video !== video) {\n // Video was changed before it loaded\n return;\n }\n\n const videoTexture = new THREE.VideoTexture(video);\n this.videoMaterial.map = videoTexture;\n this.videoMaterial.needsUpdate = true;\n this.mesh.material = this.videoMaterial;\n this.loadedVideoState.videoTexture = videoTexture;\n\n this.syncVideoTime();\n this.updateWidthAndHeight();\n this.updateMaterialEmissiveIntensity();\n });\n }\n }\n\n if (this.videoSource) {\n this.syncVideoTime();\n }\n }\n\n private clearSource() {\n if (this.videoSource) {\n this.videoSource.dispose();\n this.videoSource = null;\n }\n if (this.loadedVideoState) {\n const tag = this.loadedVideoState.video;\n // There is an existing src - stop playing to allow changing it\n tag.pause();\n tag.src = \"\";\n tag.load();\n this.loadedVideoState = null;\n this.mesh.material = disabledVideoMaterial;\n this.updateWidthAndHeight();\n }\n }\n\n dispose() {\n this.clearSource();\n if (this.loadedVideoState) {\n this.loadedVideoState = null;\n }\n }\n\n private updateMaterialEmissiveIntensity() {\n if (this.loadedVideoState && this.loadedVideoState.videoTexture) {\n if (this.video.props.emissive > 0) {\n this.videoMaterial.emissive = new THREE.Color(0xffffff);\n this.videoMaterial.emissiveMap = this.loadedVideoState.videoTexture;\n this.videoMaterial.emissiveIntensity = this.video.props.emissive;\n this.videoMaterial.needsUpdate = true;\n } else {\n this.videoMaterial.emissive = new THREE.Color(0x000000);\n this.videoMaterial.emissiveMap = null;\n this.videoMaterial.emissiveIntensity = 1;\n this.videoMaterial.needsUpdate = true;\n }\n }\n }\n\n private updateWidthAndHeight() {\n const mesh = this.mesh;\n\n const { width, height } = calculateContentSize({\n content: this.loadedVideoState\n ? {\n width: this.loadedVideoState.video.videoWidth,\n height: this.loadedVideoState.video.videoHeight,\n }\n : undefined,\n width: this.video.props.width,\n height: this.video.props.height,\n });\n mesh.scale.x = width;\n mesh.scale.y = height;\n\n this.updateMeshCallback();\n }\n}\n", "import {\n EventHandlerCollection,\n getRelativePositionAndRotationRelativeToObject,\n MElement,\n TransformableElement,\n} from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nconst mouseMovePixelsThreshold = 10;\nconst mouseMoveTimeThresholdMilliseconds = 500;\n\n/**\n * The ThreeJSClickTrigger class is responsible for handling click events on the MML scene and raycasts into the scene to\n * determine which object was clicked and then dispatches events to those elements.\n */\nexport class ThreeJSClickTrigger {\n private eventHandlerCollection: EventHandlerCollection = new EventHandlerCollection();\n private raycaster: THREE.Raycaster;\n private mouseDownTime: number | null = null;\n private mouseMoveDelta = 0;\n\n static init(\n clickTarget: Document | HTMLElement,\n rootContainer: THREE.Object3D,\n camera: THREE.Camera,\n ): ThreeJSClickTrigger {\n return new ThreeJSClickTrigger(clickTarget, rootContainer, camera);\n }\n\n private constructor(\n private clickTarget: Document | HTMLElement,\n private rootContainer: THREE.Object3D,\n private camera: THREE.Camera,\n ) {\n this.raycaster = new THREE.Raycaster();\n\n this.eventHandlerCollection.add(clickTarget, \"mousedown\", this.handleMouseDown.bind(this));\n this.eventHandlerCollection.add(clickTarget, \"mouseup\", this.handleMouseUp.bind(this));\n this.eventHandlerCollection.add(clickTarget, \"mousemove\", this.handleMouseMove.bind(this));\n }\n\n private handleMouseDown() {\n this.mouseDownTime = Date.now();\n this.mouseMoveDelta = 0;\n }\n\n private handleMouseUp(event: MouseEvent) {\n if (!this.mouseDownTime) {\n return;\n }\n const duration = Date.now() - this.mouseDownTime;\n this.mouseDownTime = null;\n if (\n this.mouseMoveDelta < mouseMovePixelsThreshold &&\n duration < mouseMoveTimeThresholdMilliseconds\n ) {\n this.handleClick(event);\n }\n }\n\n private handleMouseMove(event: MouseEvent) {\n if (this.mouseDownTime) {\n this.mouseMoveDelta += Math.abs(event.movementX) + Math.abs(event.movementY);\n }\n }\n\n private handleClick(event: MouseEvent) {\n if ((event.detail as any).element) {\n // Avoid infinite loop of handling click events that originated from this trigger\n return;\n }\n let x = 0;\n let y = 0;\n if (!document.pointerLockElement) {\n let width = window.innerWidth;\n let height = window.innerHeight;\n if (this.clickTarget instanceof HTMLElement) {\n width = this.clickTarget.offsetWidth;\n height = this.clickTarget.offsetHeight;\n }\n x = (event.offsetX / width) * 2 - 1;\n y = -((event.offsetY / height) * 2 - 1);\n }\n this.raycaster.setFromCamera(new THREE.Vector2(x, y), this.camera);\n const intersections = this.raycaster.intersectObject(this.rootContainer, true);\n if (intersections.length > 0) {\n for (const intersection of intersections) {\n let obj: THREE.Object3D | null = intersection.object;\n while (obj) {\n /*\n Ignore scene objects that have a transparent or wireframe material\n */\n if (this.isMaterialIgnored(obj)) {\n break;\n }\n\n const mElement = MElement.getMElementFromObject(obj);\n if (mElement && mElement instanceof TransformableElement && mElement.isClickable()) {\n // let's get the intersection point relative to the element origin\n\n const elementRelative = getRelativePositionAndRotationRelativeToObject(\n {\n position: intersection.point,\n rotation: {\n x: 0,\n y: 0,\n z: 0,\n },\n },\n mElement,\n );\n\n mElement.dispatchEvent(\n new CustomEvent(\"click\", {\n bubbles: true,\n detail: {\n position: {\n ...elementRelative.position,\n },\n },\n }),\n );\n return;\n }\n obj = obj.parent;\n }\n }\n }\n }\n\n dispose() {\n this.eventHandlerCollection.clear();\n }\n\n private isMaterialIgnored(obj: THREE.Object3D): boolean {\n const mesh = obj as THREE.Mesh;\n if (mesh) {\n if (\n ((mesh.material as THREE.Material) &&\n (mesh.material as THREE.Material).transparent &&\n (mesh.material as THREE.Material).opacity < 1) ||\n ((mesh.material as THREE.MeshLambertMaterial) &&\n (mesh.material as THREE.MeshLambertMaterial).wireframe) ||\n ((mesh.material as THREE.MeshPhongMaterial) &&\n (mesh.material as THREE.MeshPhongMaterial).wireframe) ||\n ((mesh.material as THREE.MeshPhysicalMaterial) &&\n (mesh.material as THREE.MeshPhysicalMaterial).wireframe) ||\n ((mesh.material as THREE.MeshStandardMaterial) &&\n (mesh.material as THREE.MeshStandardMaterial).wireframe) ||\n ((mesh.material as THREE.LineBasicMaterial) &&\n (mesh.material as THREE.LineBasicMaterial).isLineBasicMaterial)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n", "import { MMLGraphicsInterface } from \"@mml-io/mml-web\";\n\nimport * as ThreeJSElements from \"./elements\";\nimport { ThreeJSGraphicsAdapter } from \"./ThreeJSGraphicsAdapter\";\n\nexport const ThreeJSGraphicsInterface: MMLGraphicsInterface<ThreeJSGraphicsAdapter> = {\n MElementGraphicsInterface: (element) => new ThreeJSElements.ThreeJSMElement(element),\n MMLDebugHelperGraphicsInterface: (debugHelper) =>\n new ThreeJSElements.ThreeJSDebugHelper(debugHelper),\n MMLAudioGraphicsInterface: (element) => new ThreeJSElements.ThreeJSAudio(element),\n MMLChatProbeGraphicsInterface: (element) => new ThreeJSElements.ThreeJSChatProbe(element),\n MMLCubeGraphicsInterface: (element) => new ThreeJSElements.ThreeJSCube(element),\n MMLCylinderGraphicsInterface: (element) => new ThreeJSElements.ThreeJSCylinder(element),\n MMLFrameGraphicsInterface: (element) => new ThreeJSElements.ThreeJSFrame(element),\n MMLImageGraphicsInterface: (element, updateMeshCallback) =>\n new ThreeJSElements.ThreeJSImage(element, updateMeshCallback),\n MMLInteractionGraphicsInterface: (element) => new ThreeJSElements.ThreeJSInteraction(element),\n MMLLabelGraphicsInterface: (element) => new ThreeJSElements.ThreeJSLabel(element),\n MMLLightGraphicsInterface: (element) => new ThreeJSElements.ThreeJSLight(element),\n MMLLinkGraphicsInterface: (element) => new ThreeJSElements.ThreeJSLink(element),\n MMLModelGraphicsInterface: (element, updateMeshCallback) =>\n new ThreeJSElements.ThreeJSModel(element, updateMeshCallback),\n MMLPlaneGraphicsInterface: (element) => new ThreeJSElements.ThreeJSPlane(element),\n MMLPositionProbeGraphicsInterface: (element) => new ThreeJSElements.ThreeJSPositionProbe(element),\n MMLPromptGraphicsInterface: (element) => new ThreeJSElements.ThreeJSPrompt(element),\n MMLSphereGraphicsInterface: (element) => new ThreeJSElements.ThreeJSSphere(element),\n MMLTransformableGraphicsInterface: (element) => new ThreeJSElements.ThreeJSTransformable(element),\n MMLVideoGraphicsInterface: (element, updateMeshCallback: () => void) =>\n new ThreeJSElements.ThreeJSVideo(element, updateMeshCallback),\n RemoteDocumentGraphicsInterface: (element) => new ThreeJSElements.ThreeJSRemoteDocument(element),\n};\n", "import { Interaction } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"./ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSInteractionAdapter {\n private static worldPos = new THREE.Vector3();\n\n private static matrix = new THREE.Matrix4();\n private static frustum = new THREE.Frustum();\n\n private static raycaster = new THREE.Raycaster();\n private static intersections = new Array<THREE.Intersection<THREE.Object3D>>();\n private static direction = new THREE.Vector3();\n\n static interactionShouldShowDistance(\n interaction: Interaction<ThreeJSGraphicsAdapter>,\n camera: THREE.Camera,\n scene: THREE.Scene,\n ): number | null {\n const worldPos = interaction\n .getContainer()\n .getWorldPosition(ThreeJSInteractionAdapter.worldPos);\n\n const cameraPos = camera.position;\n const distance = cameraPos.distanceTo(worldPos);\n if (distance > interaction.props.range) {\n return null;\n }\n\n if (interaction.props.inFocus) {\n ThreeJSInteractionAdapter.matrix.multiplyMatrices(\n camera.projectionMatrix,\n camera.matrixWorldInverse,\n );\n ThreeJSInteractionAdapter.frustum.setFromProjectionMatrix(ThreeJSInteractionAdapter.matrix);\n if (!ThreeJSInteractionAdapter.frustum.containsPoint(worldPos)) {\n return null;\n }\n }\n\n if (interaction.props.lineOfSight) {\n const raycastResults = ThreeJSInteractionAdapter.getRaycastResults(\n cameraPos,\n worldPos,\n distance,\n scene,\n );\n if (raycastResults.length > 0) {\n for (const result of raycastResults) {\n if (!ThreeJSInteractionAdapter.hasAncestor(result.object, interaction.getContainer())) {\n return null;\n }\n }\n }\n }\n\n return distance;\n }\n\n static getRaycastResults(\n a: THREE.Vector3,\n b: THREE.Vector3,\n distance: number,\n scene: THREE.Scene,\n ) {\n ThreeJSInteractionAdapter.direction.copy(b);\n ThreeJSInteractionAdapter.direction.sub(a);\n ThreeJSInteractionAdapter.direction.normalize();\n\n ThreeJSInteractionAdapter.raycaster.set(a, ThreeJSInteractionAdapter.direction);\n ThreeJSInteractionAdapter.raycaster.near = 0;\n ThreeJSInteractionAdapter.raycaster.far = distance;\n\n ThreeJSInteractionAdapter.intersections.length = 0;\n ThreeJSInteractionAdapter.raycaster.intersectObject(\n scene,\n true,\n ThreeJSInteractionAdapter.intersections,\n );\n return ThreeJSInteractionAdapter.intersections;\n }\n\n static hasAncestor(object: THREE.Object3D, ancestor: THREE.Object3D): boolean {\n let parent = object.parent;\n while (parent !== null) {\n if (parent === ancestor) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n }\n}\n"],
5
- "mappings": ";AAAA,SAAS,aAA0B;AACnC,SAAS,qBAAqB;AAC9B,SAAS,8BAA8B;AACvC,YAAY,WAAW;AACvB,SAAS,6BAA6B;AAItC,IAAM,uBAAuB;AAC7B,IAAM,qBAAqB,IAAU,qBAAe,sBAAsB,GAAG,CAAC;AAC9E,IAAM,qBAAqB,IAAU,wBAAkB;AAAA,EACrD,WAAW;AAAA,EACX,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,OAAO;AACT,CAAC;AACD,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;AAE3B,SAAS,sBACP,SACA,QACA,SACa;AACb,QAAM,gBAAgB,QAAQ;AAAA,IAC5B,OAAO;AAAA,IACP,KAAK,KAAK,UAAU,OAAO,UAAU;AAAA,IACrC,OAAO;AAAA,EACT;AACA,WAAS,gBAAgB,GAAG,gBAAgB,OAAO,kBAAkB,iBAAiB;AACpF,UAAM,cAAc,OAAO,eAAe,aAAa;AACvD,UAAM,qBAAqB,cAAc,eAAe,aAAa;AACrE,uBAAmB,IAAI,aAAa,CAAC;AAAA,EACvC;AACA,SAAO;AACT;AAEO,IAAM,eAAN,cAA2B,cAAsC;AAAA,EAqCtE,YAAoB,OAAsC;AACxD,UAAM,KAAK;AADO;AApCpB,SAAQ,mBAAqF;AAG7F,SAAQ,mCAAmC,MAAM;AAC/C,WAAK,cAAc;AAAA,IACrB;AAGA,SAAQ,oBAA2C;AACnD,SAAQ,4BAA4B,IAAI,uBAAuB,GAAG,MAAM,OAAO,MAAM;AAIrF,SAAQ,mBAqBG;AAKT,SAAK,uBAAuB,KAA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O;AACpB,WAAO,WAAW,MAAM;AACtB,UAAI,WAAW,UAAU;AACvB,eAAO;AAAA,MACT;AACA,eAAS,OAAO;AAAA,IAClB;AACA,WAAO;AAAA,EACT;AACF;AAxFa,2BACI,WAAW,IAAU,gBAAQ;AADjC,2BAGI,SAAS,IAAU,gBAAQ;AAH/B,2BAII,UAAU,IAAU,gBAAQ;AAJhC,2BAMI,YAAY,IAAU,kBAAU;AANpC,2BAOI,gBAAgB,IAAI,MAA0C;AAPlE,2BAQI,YAAY,IAAU,gBAAQ;AARxC,IAAM,4BAAN;",
4
+ "sourcesContent": ["import { Audio, MAudioProps } from \"@mml-io/mml-web\";\nimport { AudioGraphics } from \"@mml-io/mml-web\";\nimport { LoadingInstanceManager } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\nimport { PositionalAudioHelper } from \"three/addons/helpers/PositionalAudioHelper.js\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nconst debugAudioSphereSize = 0.25;\nconst debugAudioGeometry = new THREE.SphereGeometry(debugAudioSphereSize, 4, 2);\nconst debugAudioMaterial = new THREE.MeshBasicMaterial({\n wireframe: true,\n fog: false,\n toneMapped: false,\n color: 0x00ff00,\n});\nconst audioRefDistance = 1;\nconst audioRolloffFactor = 1;\n\nfunction extendAudioToDuration(\n context: AudioContext,\n buffer: AudioBuffer,\n seconds: number,\n): AudioBuffer {\n const updatedBuffer = context.createBuffer(\n buffer.numberOfChannels,\n Math.ceil(seconds * buffer.sampleRate),\n buffer.sampleRate,\n );\n for (let channelNumber = 0; channelNumber < buffer.numberOfChannels; channelNumber++) {\n const channelData = buffer.getChannelData(channelNumber);\n const updatedChannelData = updatedBuffer.getChannelData(channelNumber);\n updatedChannelData.set(channelData, 0);\n }\n return updatedBuffer;\n}\n\nexport class ThreeJSAudio extends AudioGraphics<ThreeJSGraphicsAdapter> {\n private audioDebugHelper: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial> | null = null;\n private audioDebugConeX: PositionalAudioHelper | null;\n private audioDebugConeY: PositionalAudioHelper | null;\n private audioContextStateChangedListener = () => {\n this.syncAudioTime();\n };\n\n private documentTimeListener: { remove: () => void };\n private delayedPauseTimer: NodeJS.Timeout | null = null;\n private srcLoadingInstanceManager = new LoadingInstanceManager(`${Audio.tagName}.src`);\n\n private positionalAudio: THREE.PositionalAudio;\n\n private loadedAudioState: {\n loadedAudio:\n | {\n mode: \"LOADED\";\n buffer: AudioBuffer;\n currentSource: {\n sourceNode: AudioBufferSourceNode;\n contextStartTime: number;\n } | null;\n paddedBuffer?: {\n buffer: AudioBuffer;\n totalDuration: number;\n };\n }\n | {\n mode: \"LOADING\";\n srcLoadPromise: Promise<AudioBuffer>;\n abortController: AbortController;\n }\n | null;\n currentSrc: string;\n } | null = null;\n\n constructor(private audio: Audio<ThreeJSGraphicsAdapter>) {\n super(audio);\n\n this.documentTimeListener = this.audio.addDocumentTimeListener(() => {\n if (this.loadedAudioState) {\n this.syncAudioTime();\n }\n });\n\n const audioListener = this.getAudioListener();\n this.positionalAudio = new THREE.PositionalAudio(audioListener);\n this.positionalAudio.context.addEventListener(\n \"statechange\",\n this.audioContextStateChangedListener,\n );\n this.positionalAudio.setVolume(this.audio.props.volume);\n this.positionalAudio.setDirectionalCone(\n this.audio.props.coneFalloffAngle ?? 360,\n this.audio.props.coneAngle,\n 0,\n );\n this.positionalAudio.setRefDistance(audioRefDistance);\n this.positionalAudio.setRolloffFactor(audioRolloffFactor);\n this.audio.getContainer().add(this.positionalAudio);\n\n this.updateAudio();\n this.updateDebugVisualisation();\n }\n\n disable(): void {}\n\n enable(): void {}\n\n public syncAudioTime() {\n const audioContext = this.positionalAudio.context;\n if (audioContext.state !== \"running\") {\n return;\n }\n\n if (this.delayedPauseTimer !== null) {\n clearTimeout(this.delayedPauseTimer);\n this.delayedPauseTimer = null;\n }\n\n if (\n !this.loadedAudioState ||\n !this.loadedAudioState.loadedAudio ||\n this.loadedAudioState.loadedAudio.mode !== \"LOADED\"\n ) {\n return;\n }\n\n const loadedAudio = this.loadedAudioState.loadedAudio;\n const audioBuffer = loadedAudio.buffer;\n let currentSource = loadedAudio.currentSource;\n\n if (!this.audio.props.enabled || this.audio.isDisabled()) {\n if (currentSource) {\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n }\n return;\n }\n\n const documentTime = this.audio.getDocumentTime();\n if (this.audio.props.pauseTime !== null) {\n const timeUntilPause = this.audio.props.pauseTime - documentTime;\n if (timeUntilPause < 2) {\n // The audio should be paused because the pauseTime is in the past or very close\n if (currentSource) {\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n }\n return;\n } else {\n // The pause time is in the future\n const delayedPauseTimer = setTimeout(() => {\n if (this.delayedPauseTimer === delayedPauseTimer) {\n this.delayedPauseTimer = null;\n }\n this.syncAudioTime();\n }, timeUntilPause);\n this.delayedPauseTimer = delayedPauseTimer;\n }\n }\n\n const currentTime = (documentTime - this.audio.props.startTime) / 1000;\n const audioDuration = audioBuffer.duration;\n\n let loopDurationSeconds: number | null = null;\n if (this.audio.props.loopDuration !== null && this.audio.props.loopDuration > 0) {\n loopDurationSeconds = this.audio.props.loopDuration / 1000;\n }\n\n let desiredAudioTime: number;\n if (this.audio.props.loop) {\n if (currentTime < 0) {\n desiredAudioTime = currentTime;\n } else {\n if (loopDurationSeconds === null) {\n desiredAudioTime = currentTime % audioDuration;\n } else {\n desiredAudioTime = currentTime % loopDurationSeconds;\n }\n }\n } else {\n desiredAudioTime = currentTime;\n if (desiredAudioTime > audioDuration) {\n // The audio should stop because it has reached the end\n if (currentSource) {\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n }\n return;\n }\n }\n\n const loopDurationLongerThanAudioDuration =\n loopDurationSeconds && loopDurationSeconds > audioDuration;\n const playbackLength = loopDurationSeconds ? loopDurationSeconds : audioDuration;\n\n if (currentSource) {\n if (currentSource.sourceNode.loop !== this.audio.props.loop) {\n // The loop setting has changed - remove the existing audio source and a new one will be created\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else if (\n loopDurationSeconds !== null &&\n loopDurationLongerThanAudioDuration &&\n (!loadedAudio.paddedBuffer || loadedAudio.paddedBuffer.totalDuration < loopDurationSeconds)\n ) {\n /*\n The loop duration is set, and it is longer than the audio file, and\n either there is no existing padding, or the existing padding is too\n short. Dispose of the existing audio source and create a new one.\n */\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else if (\n loopDurationSeconds === null &&\n currentSource.sourceNode.loopEnd !== audioBuffer.duration\n ) {\n // The loop duration has been removed - reset the loop end to the audio duration\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else {\n if (this.audio.props.startTime > documentTime) {\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else {\n const unloopedCurrentAudioPoint =\n (audioContext.currentTime - currentSource.contextStartTime) /\n currentSource.sourceNode.playbackRate.value;\n\n if (unloopedCurrentAudioPoint < 0) {\n // Audio should not be playing yet, so stop it and it will be rescheduled\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else {\n if (\n loopDurationSeconds !== null &&\n currentSource.sourceNode.loopEnd !== loopDurationSeconds\n ) {\n currentSource.sourceNode.loopEnd = loopDurationSeconds;\n }\n\n const currentAudioPoint = unloopedCurrentAudioPoint % playbackLength;\n\n let delta = desiredAudioTime - currentAudioPoint;\n if (this.audio.props.loop) {\n // Check if the delta wrapping around is smaller (i.e. the desired and current are closer together if we wrap around)\n const loopedDelta = delta - playbackLength;\n if (Math.abs(delta) > Math.abs(loopedDelta)) {\n delta = loopedDelta;\n }\n }\n\n if (Math.abs(delta) > 0.5) {\n // We need to skip to the correct point as playback has drifted too far. Remove the audio source and a new one will be created\n currentSource.sourceNode.stop();\n loadedAudio.currentSource = null;\n currentSource = null;\n } else {\n if (Math.abs(delta) < 0.1) {\n // Do nothing - this is close enough - set the playback rate to 1\n currentSource.sourceNode.playbackRate.value = 1;\n } else {\n if (delta > 0) {\n currentSource.sourceNode.playbackRate.value = 1.01;\n } else {\n currentSource.sourceNode.playbackRate.value = 0.99;\n }\n }\n // Calculate a start time that produces the current time as calculated time the next time it is checked\n currentSource.contextStartTime =\n audioContext.currentTime -\n currentAudioPoint / currentSource.sourceNode.playbackRate.value;\n }\n }\n }\n }\n }\n\n if (!currentSource) {\n // There is no current source (or it was removed) - create a new one\n const currentSourceNode = this.positionalAudio.context.createBufferSource();\n\n let buffer = audioBuffer;\n if (loopDurationSeconds && loopDurationLongerThanAudioDuration) {\n // The loop duration requires longer audio than the original audio - pad it with silence\n if (\n loadedAudio.paddedBuffer &&\n loadedAudio.paddedBuffer.totalDuration === loopDurationSeconds\n ) {\n // The padding is already the correct length\n buffer = loadedAudio.paddedBuffer.buffer;\n } else {\n const paddedBuffer = extendAudioToDuration(\n this.positionalAudio.context,\n audioBuffer,\n loopDurationSeconds,\n );\n loadedAudio.paddedBuffer = {\n buffer: paddedBuffer,\n totalDuration: loopDurationSeconds,\n };\n buffer = paddedBuffer;\n }\n }\n\n currentSourceNode.buffer = buffer;\n currentSourceNode.loop = this.audio.props.loop;\n currentSourceNode.loopStart = 0;\n if (loopDurationSeconds) {\n currentSourceNode.loopEnd = loopDurationSeconds;\n } else {\n currentSourceNode.loopEnd = audioBuffer.duration;\n }\n let contextStartTime;\n if (desiredAudioTime < 0) {\n // The audio should not have started yet - schedule it to start in the future\n const timeFromNowToStart = -desiredAudioTime;\n contextStartTime = audioContext.currentTime + timeFromNowToStart;\n currentSourceNode.start(contextStartTime);\n } else {\n /*\n The audio should have been playing already. Start playing from an\n offset into the file and set the contextStartTime to when it should\n have started\n */\n contextStartTime = audioContext.currentTime - desiredAudioTime;\n currentSourceNode.start(0, desiredAudioTime);\n }\n loadedAudio.currentSource = {\n sourceNode: currentSourceNode,\n contextStartTime,\n };\n this.positionalAudio.setNodeSource(currentSourceNode);\n }\n }\n\n private clearAudio() {\n if (this.loadedAudioState) {\n if (this.loadedAudioState.loadedAudio) {\n if (this.loadedAudioState.loadedAudio.mode === \"LOADING\") {\n this.loadedAudioState.loadedAudio.abortController.abort();\n } else {\n if (this.loadedAudioState.loadedAudio.currentSource?.sourceNode) {\n this.loadedAudioState.loadedAudio.currentSource.sourceNode.stop();\n }\n }\n }\n this.loadedAudioState = null;\n }\n }\n\n private updateAudio() {\n if (!this.audio.isConnected) {\n return;\n }\n\n const audioListener = this.getAudioListener();\n const audioContext = audioListener.context;\n\n if (!this.audio.props.src) {\n this.clearAudio();\n } else {\n const contentAddress = this.audio.contentSrcToContentAddress(this.audio.props.src);\n if (this.loadedAudioState && this.loadedAudioState.currentSrc === contentAddress) {\n // Already loaded this audio src\n } else {\n this.clearAudio();\n\n const abortController = new AbortController();\n\n this.srcLoadingInstanceManager.start(\n this.audio.getLoadingProgressManager(),\n contentAddress,\n );\n const srcLoadPromise = this.asyncLoadSourceAsset(\n contentAddress,\n abortController,\n audioContext,\n (loaded, total) => {\n this.srcLoadingInstanceManager.setProgress(loaded / total);\n },\n );\n this.loadedAudioState = {\n loadedAudio: {\n mode: \"LOADING\",\n abortController,\n srcLoadPromise,\n },\n currentSrc: contentAddress,\n };\n srcLoadPromise\n .then((buffer) => {\n if (\n this.loadedAudioState &&\n this.loadedAudioState.loadedAudio?.mode === \"LOADING\" &&\n this.loadedAudioState.loadedAudio.srcLoadPromise === srcLoadPromise\n ) {\n this.loadedAudioState.loadedAudio = {\n mode: \"LOADED\",\n buffer,\n currentSource: null,\n };\n this.srcLoadingInstanceManager.finish();\n this.syncAudioTime();\n }\n })\n .catch((e) => {\n if (\n this.loadedAudioState &&\n this.loadedAudioState.loadedAudio?.mode === \"LOADING\" &&\n this.loadedAudioState.loadedAudio.srcLoadPromise === srcLoadPromise\n ) {\n console.error(\"Failed to load audio\", e);\n this.srcLoadingInstanceManager.error(e);\n this.clearAudio();\n }\n });\n }\n }\n\n this.syncAudioTime();\n }\n\n async asyncLoadSourceAsset(\n contentAddress: string,\n abortController: AbortController,\n audioContext: AudioContext,\n // TODO - implement progress\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onProgress: (loaded: number, total: number) => void,\n ): Promise<AudioBuffer> {\n return new Promise((resolve, reject) => {\n (async () => {\n if (contentAddress.startsWith(\"data:\")) {\n // Construct an AudioBuffer from the data URL\n const base64 = contentAddress.split(\",\", 2)[1];\n if (!base64) {\n reject(new Error(\"Invalid data URL\"));\n return;\n }\n let arrayBuffer;\n\n try {\n const binary = atob(base64);\n const uint8Array = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n uint8Array[i] = binary.charCodeAt(i);\n }\n arrayBuffer = uint8Array.buffer;\n } catch (e) {\n console.error(\"Failed to decode base64 data URL\", e);\n return;\n }\n audioContext\n .decodeAudioData(arrayBuffer)\n .then((audioBuffer) => {\n if (abortController.signal.aborted) {\n return;\n }\n resolve(audioBuffer);\n })\n .catch((e) => {\n console.error(\"Failed to decode data URI audio data\", e);\n });\n return;\n }\n\n const response = await fetch(contentAddress, {\n signal: abortController.signal,\n });\n\n if (response.ok) {\n response\n .arrayBuffer()\n .then((buffer) => {\n if (abortController.signal.aborted) {\n return;\n }\n audioContext.decodeAudioData(buffer).then((audioBuffer) => {\n if (abortController.signal.aborted) {\n return;\n }\n resolve(audioBuffer);\n });\n })\n .catch((e) => {\n console.error(\"Failed to decode fetched audio data\", e);\n });\n } else {\n console.error(\"Failed to fetch audio data\", response);\n }\n })();\n });\n }\n\n setSrc(): void {\n this.updateAudio();\n }\n setStartTime(): void {\n if (this.loadedAudioState) {\n this.syncAudioTime();\n }\n }\n setPauseTime(): void {\n if (this.loadedAudioState) {\n this.syncAudioTime();\n }\n }\n setLoopDuration(): void {\n if (this.loadedAudioState) {\n this.syncAudioTime();\n }\n }\n setLoop(): void {\n this.updateAudio();\n }\n setEnabled(): void {\n this.updateAudio();\n }\n setVolume(volume: number): void {\n this.positionalAudio.setVolume(volume);\n }\n setConeAngle(coneAngle: number | null, mAudioProps: MAudioProps): void {\n this.positionalAudio.setDirectionalCone(\n mAudioProps.coneAngle,\n mAudioProps.coneFalloffAngle ?? 360,\n 0,\n );\n this.updateDebugVisualisation();\n }\n setConeFalloffAngle(coneFalloffAngle: number | null, mAudioProps: MAudioProps): void {\n this.positionalAudio.setDirectionalCone(\n mAudioProps.coneAngle,\n mAudioProps.coneFalloffAngle ?? 360,\n 0,\n );\n this.updateDebugVisualisation();\n }\n\n setDebug(): void {\n this.updateDebugVisualisation();\n }\n\n dispose() {\n if (this.positionalAudio) {\n this.positionalAudio.context.removeEventListener(\n \"statechange\",\n this.audioContextStateChangedListener,\n );\n this.positionalAudio.disconnect();\n this.positionalAudio.removeFromParent();\n }\n\n this.clearAudio();\n\n if (this.delayedPauseTimer) {\n clearTimeout(this.delayedPauseTimer);\n this.delayedPauseTimer = null;\n }\n this.documentTimeListener.remove();\n this.clearDebugVisualisation();\n this.srcLoadingInstanceManager.dispose();\n }\n\n private clearDebugVisualisation() {\n if (this.audioDebugHelper) {\n this.audioDebugHelper.removeFromParent();\n this.audioDebugHelper = null;\n }\n if (this.audioDebugConeX) {\n this.audioDebugConeX.removeFromParent();\n this.audioDebugConeX = null;\n this.audioDebugConeY?.removeFromParent();\n this.audioDebugConeY = null;\n }\n }\n\n private updateDebugVisualisation() {\n if (!this.audio.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (!this.audioDebugHelper) {\n this.audioDebugHelper = new THREE.Mesh(debugAudioGeometry, debugAudioMaterial);\n this.audio.getContainer().add(this.audioDebugHelper);\n }\n if (!this.audioDebugConeX && this.audio.props.coneAngle) {\n this.audioDebugConeX = new PositionalAudioHelper(this.positionalAudio, 10);\n this.positionalAudio.add(this.audioDebugConeX);\n this.audioDebugConeY = new PositionalAudioHelper(this.positionalAudio, 10);\n this.audioDebugConeY.rotation.z = Math.PI / 2;\n this.positionalAudio.add(this.audioDebugConeY);\n }\n if (!this.audio.props.coneAngle && this.audioDebugConeX) {\n this.audioDebugConeX.removeFromParent();\n this.audioDebugConeX = null;\n this.audioDebugConeY?.removeFromParent();\n this.audioDebugConeY = null;\n }\n }\n this.audioDebugConeX?.update();\n this.audioDebugConeY?.update();\n }\n\n private getAudioListener() {\n return this.audio.getScene().getGraphicsAdapter().getAudioListener();\n }\n}\n", "import { ChatProbe } from \"@mml-io/mml-web\";\nimport { ChatProbeGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSChatProbe extends ChatProbeGraphics<ThreeJSGraphicsAdapter> {\n private static DebugGeometry = new THREE.SphereGeometry(1, 16, 16, 1);\n private static DebugMaterial = new THREE.MeshBasicMaterial({\n color: 0xffff00,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n\n private debugMesh: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial> | null = null;\n\n constructor(private chatProbe: ChatProbe<ThreeJSGraphicsAdapter>) {\n super(chatProbe);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setRange(): void {\n this.updateDebugVisualisation();\n }\n\n setDebug() {\n this.updateDebugVisualisation();\n }\n\n private clearDebugVisualisation() {\n if (this.debugMesh) {\n this.debugMesh.removeFromParent();\n this.debugMesh = null;\n }\n }\n\n private updateDebugVisualisation() {\n if (!this.chatProbe.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (this.chatProbe.isConnected && !this.debugMesh) {\n const mesh = new THREE.Mesh(ThreeJSChatProbe.DebugGeometry, ThreeJSChatProbe.DebugMaterial);\n mesh.castShadow = false;\n mesh.receiveShadow = false;\n this.debugMesh = mesh;\n this.chatProbe.getContainer().add(this.debugMesh);\n }\n\n if (this.debugMesh) {\n this.debugMesh.scale.set(\n this.chatProbe.props.range,\n this.chatProbe.props.range,\n this.chatProbe.props.range,\n );\n }\n }\n }\n\n dispose() {\n this.clearDebugVisualisation();\n }\n}\n", "import { Cube } from \"@mml-io/mml-web\";\nimport { CubeGraphics } from \"@mml-io/mml-web\";\nimport { MMLColor } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSCube extends CubeGraphics<ThreeJSGraphicsAdapter> {\n static boxGeometry = new THREE.BoxGeometry(1, 1, 1);\n private mesh: THREE.Mesh<THREE.BoxGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial;\n constructor(private cube: Cube<ThreeJSGraphicsAdapter>) {\n super(cube);\n\n this.material = new THREE.MeshStandardMaterial({\n color: new THREE.Color(cube.props.color.r, cube.props.color.g, cube.props.color.b),\n });\n this.mesh = new THREE.Mesh(ThreeJSCube.boxGeometry, this.material);\n this.mesh.castShadow = cube.props.castShadows;\n this.mesh.receiveShadow = true;\n this.cube.getContainer().add(this.mesh);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D<THREE.Object3DEventMap> {\n return this.mesh;\n }\n\n setColor(color: MMLColor): void {\n this.material.color = new THREE.Color(color.r, color.g, color.b);\n }\n\n setWidth(width: number): void {\n this.mesh.scale.x = width;\n }\n\n setHeight(height: number): void {\n this.mesh.scale.y = height;\n }\n\n setDepth(depth: number): void {\n this.mesh.scale.z = depth;\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n setOpacity(opacity: number): void {\n const needsUpdate = this.material.transparent === (opacity === 1);\n this.material.transparent = opacity !== 1;\n this.material.needsUpdate = needsUpdate;\n this.material.opacity = opacity;\n }\n\n dispose() {}\n}\n", "import { Cylinder, CylinderGraphics, MMLColor } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSCylinder extends CylinderGraphics<ThreeJSGraphicsAdapter> {\n static cylinderGeometry = new THREE.CylinderGeometry(0.5, 0.5, 1);\n private mesh: THREE.Mesh<THREE.CylinderGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial;\n\n constructor(private cylinder: Cylinder<ThreeJSGraphicsAdapter>) {\n super(cylinder);\n\n this.material = new THREE.MeshStandardMaterial({\n color: new THREE.Color(\n cylinder.props.color.r,\n cylinder.props.color.g,\n cylinder.props.color.b,\n ),\n });\n this.mesh = new THREE.Mesh(ThreeJSCylinder.cylinderGeometry, this.material);\n this.mesh.castShadow = cylinder.props.castShadows;\n this.mesh.receiveShadow = true;\n this.cylinder.getContainer().add(this.mesh);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n setColor(color: MMLColor): void {\n this.material.color = new THREE.Color(color.r, color.g, color.b);\n }\n\n setRadius(radius: number): void {\n this.mesh.scale.x = radius * 2;\n this.mesh.scale.z = radius * 2;\n }\n\n setHeight(height: number): void {\n this.mesh.scale.y = height;\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n setOpacity(opacity: number): void {\n const needsUpdate = this.material.transparent === (opacity === 1);\n this.material.transparent = opacity !== 1;\n this.material.needsUpdate = needsUpdate;\n this.material.opacity = opacity;\n }\n\n dispose() {}\n}\n", "import { DebugHelper, DebugHelperGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSDebugHelper extends DebugHelperGraphics<ThreeJSGraphicsAdapter> {\n private debugAxes: THREE.AxesHelper | null = null;\n\n constructor(private debugHelper: DebugHelper<ThreeJSGraphicsAdapter>) {\n super(debugHelper);\n this.debugAxes = new THREE.AxesHelper(1);\n this.debugHelper.getContainer().add(this.debugAxes);\n }\n\n dispose() {\n if (this.debugAxes) {\n this.debugHelper.getContainer().remove(this.debugAxes);\n }\n this.debugAxes = null;\n }\n}\n", "import { Frame } from \"@mml-io/mml-web\";\nimport { FrameGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nfunction setMeshToBoundingBox(\n mesh: THREE.Mesh,\n minX: number,\n maxX: number,\n minY: number,\n maxY: number,\n minZ: number,\n maxZ: number,\n) {\n mesh.scale.set(maxX - minX, maxY - minY, maxZ - minZ);\n mesh.position.set((maxX + minX) / 2, (maxY + minY) / 2, (maxZ + minZ) / 2);\n}\n\nexport class ThreeJSFrame extends FrameGraphics<ThreeJSGraphicsAdapter> {\n private static DebugBoxGeometry = new THREE.BoxGeometry(1, 1, 1, 1, 1, 1);\n private static DebugConstraintMaterial = new THREE.MeshBasicMaterial({\n color: 0xff0000,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n private static DebugLoadRangeMaterial = new THREE.MeshBasicMaterial({\n color: 0x00ff00,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n private static DebugUnloadRangeMaterial = new THREE.MeshBasicMaterial({\n color: 0x0000ff,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n\n private debugMeshes: {\n debugBoxConstraintMesh: THREE.Mesh<THREE.BoxGeometry, THREE.MeshBasicMaterial>;\n debugBoxLoadRangeMesh: THREE.Mesh<THREE.BoxGeometry, THREE.MeshBasicMaterial>;\n debugBoxUnloadRangeMesh: THREE.Mesh<THREE.BoxGeometry, THREE.MeshBasicMaterial>;\n } | null = null;\n\n constructor(private frame: Frame<ThreeJSGraphicsAdapter>) {\n super(frame);\n }\n\n setSrc() {\n // no-op\n }\n\n setDebug(): void {\n this.updateDebugVisualisation();\n }\n setLoadRange(): void {\n this.updateDebugVisualisation();\n }\n setUnloadRange(): void {\n this.updateDebugVisualisation();\n }\n setMinX(): void {\n this.updateDebugVisualisation();\n }\n setMaxX(): void {\n this.updateDebugVisualisation();\n }\n setMinY(): void {\n this.updateDebugVisualisation();\n }\n setMaxY(): void {\n this.updateDebugVisualisation();\n }\n setMinZ(): void {\n this.updateDebugVisualisation();\n }\n setMaxZ(): void {\n this.updateDebugVisualisation();\n }\n\n disable(): void {}\n\n enable(): void {}\n\n dispose() {}\n\n private clearDebugVisualisation() {\n if (this.debugMeshes) {\n this.debugMeshes.debugBoxConstraintMesh.removeFromParent();\n this.debugMeshes.debugBoxLoadRangeMesh.removeFromParent();\n this.debugMeshes.debugBoxUnloadRangeMesh.removeFromParent();\n this.debugMeshes = null;\n }\n }\n\n private updateDebugVisualisation() {\n if (!this.frame.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (!this.frame.isConnected) {\n return;\n }\n if (!this.debugMeshes) {\n this.debugMeshes = {\n debugBoxConstraintMesh: new THREE.Mesh(\n ThreeJSFrame.DebugBoxGeometry,\n ThreeJSFrame.DebugConstraintMaterial,\n ),\n debugBoxLoadRangeMesh: new THREE.Mesh(\n ThreeJSFrame.DebugBoxGeometry,\n ThreeJSFrame.DebugLoadRangeMaterial,\n ),\n debugBoxUnloadRangeMesh: new THREE.Mesh(\n ThreeJSFrame.DebugBoxGeometry,\n ThreeJSFrame.DebugUnloadRangeMaterial,\n ),\n };\n this.frame.getContainer().add(this.debugMeshes.debugBoxConstraintMesh);\n this.frame.getContainer().add(this.debugMeshes.debugBoxLoadRangeMesh);\n this.frame.getContainer().add(this.debugMeshes.debugBoxUnloadRangeMesh);\n }\n\n let boxBounds = this.frame.getDefinedBoxBounds();\n if (!boxBounds) {\n boxBounds = [0, 0, 0, 0, 0, 0];\n }\n\n const [minX, maxX, minY, maxY, minZ, maxZ] = boxBounds;\n this.debugMeshes.debugBoxConstraintMesh.visible = true;\n this.debugMeshes.debugBoxLoadRangeMesh.visible = true;\n this.debugMeshes.debugBoxUnloadRangeMesh.visible = true;\n\n setMeshToBoundingBox(\n this.debugMeshes.debugBoxConstraintMesh,\n minX,\n maxX,\n minY,\n maxY,\n minZ,\n maxZ,\n );\n\n if (this.frame.props.loadRange === null) {\n this.debugMeshes.debugBoxLoadRangeMesh.visible = false;\n this.debugMeshes.debugBoxUnloadRangeMesh.visible = false;\n } else {\n this.debugMeshes.debugBoxLoadRangeMesh.visible = true;\n this.debugMeshes.debugBoxUnloadRangeMesh.visible = true;\n\n setMeshToBoundingBox(\n this.debugMeshes.debugBoxLoadRangeMesh,\n minX - this.frame.props.loadRange,\n maxX + this.frame.props.loadRange,\n minY - this.frame.props.loadRange,\n maxY + this.frame.props.loadRange,\n minZ - this.frame.props.loadRange,\n maxZ + this.frame.props.loadRange,\n );\n\n setMeshToBoundingBox(\n this.debugMeshes.debugBoxUnloadRangeMesh,\n minX - this.frame.props.loadRange - this.frame.props.unloadRange,\n maxX + this.frame.props.loadRange + this.frame.props.unloadRange,\n minY - this.frame.props.loadRange - this.frame.props.unloadRange,\n maxY + this.frame.props.loadRange + this.frame.props.unloadRange,\n minZ - this.frame.props.loadRange - this.frame.props.unloadRange,\n maxZ + this.frame.props.loadRange + this.frame.props.unloadRange,\n );\n }\n }\n }\n}\n", "import {\n calculateContentSize,\n Image,\n ImageGraphics,\n LoadingInstanceManager,\n} from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSImage extends ImageGraphics<ThreeJSGraphicsAdapter> {\n private static planeGeometry = new THREE.PlaneGeometry(1, 1);\n private mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial;\n private static imageLoader = new THREE.ImageLoader();\n\n private srcApplyPromise: Promise<HTMLImageElement> | null = null;\n private loadedImage: HTMLImageElement | null;\n private loadedImageHasTransparency = false;\n private srcLoadingInstanceManager = new LoadingInstanceManager(`${Image.tagName}.src`);\n constructor(\n private image: Image<ThreeJSGraphicsAdapter>,\n private updateMeshCallback: () => void,\n ) {\n super(image, updateMeshCallback);\n\n this.material = new THREE.MeshStandardMaterial({\n color: 0xffffff,\n transparent: this.image.props.opacity !== 1 || this.loadedImageHasTransparency,\n opacity: this.image.props.opacity,\n side: THREE.DoubleSide,\n });\n this.mesh = new THREE.Mesh(ThreeJSImage.planeGeometry, this.material);\n this.mesh.castShadow = image.props.castShadows;\n this.mesh.receiveShadow = true;\n this.image.getContainer().add(this.mesh);\n }\n\n public getWidthAndHeight(): { width: number; height: number } {\n return {\n width: this.mesh.scale.x,\n height: this.mesh.scale.y,\n };\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n setWidth(): void {\n this.updateWidthAndHeight();\n }\n\n setHeight(): void {\n this.updateWidthAndHeight();\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n setOpacity(opacity: number): void {\n const shouldBeTransparent = opacity !== 1 || this.loadedImageHasTransparency;\n const needsUpdate = this.material.transparent !== shouldBeTransparent;\n\n this.material.transparent = shouldBeTransparent;\n this.material.opacity = opacity;\n\n if (needsUpdate) {\n this.material.needsUpdate = true;\n }\n }\n\n setEmissive() {\n this.updateMaterialEmissiveIntensity();\n }\n\n private updateMaterialEmissiveIntensity() {\n if (this.material) {\n const map = this.material.map as THREE.Texture;\n if (this.image.props.emissive > 0) {\n this.material.emissive = new THREE.Color(0xffffff);\n this.material.emissiveMap = map;\n this.material.emissiveIntensity = this.image.props.emissive;\n this.material.needsUpdate = true;\n } else {\n this.material.emissive = new THREE.Color(0x000000);\n this.material.emissiveMap = null;\n this.material.emissiveIntensity = 1;\n this.material.needsUpdate = true;\n }\n }\n }\n\n setSrc(newValue: string | null): void {\n const src = (newValue || \"\").trim();\n const isDataUri = src.startsWith(\"data:image/\");\n if (this.loadedImage !== null && !isDataUri) {\n // if the image has already been loaded, remove the image data from the THREE material\n this.clearImage();\n }\n if (!src) {\n // if the src attribute is empty, reset the dimensions and return\n this.updateWidthAndHeight();\n this.srcLoadingInstanceManager.abortIfLoading();\n return;\n }\n if (!this.material) {\n // if the element is not yet connected, return\n return;\n }\n\n if (isDataUri) {\n // if the src is a data url, load it directly rather than using the loader - this avoids a potential frame skip\n const image = document.createElement(\"img\");\n image.src = src;\n this.applyImage(image);\n this.srcLoadingInstanceManager.abortIfLoading();\n return;\n }\n\n const contentSrc = this.image.contentSrcToContentAddress(src);\n const srcApplyPromise = loadImageAsPromise(\n ThreeJSImage.imageLoader,\n contentSrc,\n (loaded, total) => {\n this.srcLoadingInstanceManager.setProgress(loaded / total);\n },\n );\n this.srcLoadingInstanceManager.start(this.image.getLoadingProgressManager(), contentSrc);\n this.srcApplyPromise = srcApplyPromise;\n srcApplyPromise\n .then((image: HTMLImageElement) => {\n if (this.srcApplyPromise !== srcApplyPromise || !this.material) {\n // If we've loaded a different image since, or we're no longer connected, ignore this image\n return;\n }\n this.applyImage(image);\n this.srcLoadingInstanceManager.finish();\n })\n .catch((error) => {\n console.error(\"Error loading image:\", newValue, error);\n if (this.srcApplyPromise !== srcApplyPromise || !this.material) {\n // If we've loaded a different image since, or we're no longer connected, ignore this image\n return;\n }\n this.clearImage();\n this.srcLoadingInstanceManager.error(error);\n });\n }\n\n private updateWidthAndHeight() {\n const mesh = this.mesh;\n\n const { width, height } = calculateContentSize({\n content: this.loadedImage\n ? { width: this.loadedImage.width, height: this.loadedImage.height }\n : undefined,\n width: this.image.props.width,\n height: this.image.props.height,\n });\n mesh.scale.x = width;\n mesh.scale.y = height;\n\n this.updateMeshCallback();\n }\n\n private applyImage(image: HTMLImageElement) {\n this.loadedImage = image;\n if (!image.complete) {\n // Wait for the image to be fully loaded (most likely a data uri that has not yet been decoded)\n image.addEventListener(\"load\", () => {\n if (this.loadedImage !== image) {\n // if the image has changed since we started loading, ignore this image\n return;\n }\n this.applyImage(image);\n });\n return;\n }\n this.loadedImageHasTransparency = hasTransparency(this.loadedImage);\n if (!this.material) {\n return;\n }\n this.material.map = new THREE.CanvasTexture(this.loadedImage);\n this.material.transparent = this.image.props.opacity !== 1 || this.loadedImageHasTransparency;\n this.material.alphaTest = 0.01;\n this.material.needsUpdate = true;\n this.updateMaterialEmissiveIntensity();\n this.updateWidthAndHeight();\n }\n\n private clearImage() {\n this.loadedImage = null;\n this.srcApplyPromise = null;\n if (this.material && this.material.map) {\n this.material.map.dispose();\n this.material.needsUpdate = true;\n this.material.map = null;\n this.material.alphaMap = null;\n this.material.alphaTest = 0;\n }\n this.updateWidthAndHeight();\n }\n\n dispose() {\n if (this.material.map) {\n this.material.map.dispose();\n this.material.map = null;\n }\n if (this.material.emissiveMap) {\n this.material.emissiveMap.dispose();\n this.material.emissiveMap = null;\n }\n this.material.dispose();\n this.loadedImage = null;\n this.srcLoadingInstanceManager.dispose();\n }\n}\n\nexport function loadImageAsPromise(\n imageLoader: THREE.ImageLoader,\n path: string,\n onProgress?: (loaded: number, total: number) => void,\n): Promise<HTMLImageElement> {\n return new Promise<HTMLImageElement>((resolve, reject) => {\n imageLoader.load(\n path,\n (image: HTMLImageElement) => {\n resolve(image);\n },\n (xhr: ProgressEvent) => {\n if (onProgress) {\n onProgress(xhr.loaded, xhr.total);\n }\n },\n (error: ErrorEvent) => {\n reject(error);\n },\n );\n });\n}\n\nfunction hasTransparency(image: HTMLImageElement) {\n if (image.width === 0 || image.height === 0) {\n return false;\n }\n const canvas = document.createElement(\"canvas\");\n canvas.width = image.width;\n canvas.height = image.height;\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D;\n ctx.drawImage(image, 0, 0);\n\n const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;\n\n for (let i = 3, n = imageData.length; i < n; i += 4) {\n if (imageData[i] < 255) {\n return true;\n }\n }\n return false;\n}\n", "import { Interaction } from \"@mml-io/mml-web\";\nimport { InteractionGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSInteraction extends InteractionGraphics<ThreeJSGraphicsAdapter> {\n private static DebugGeometry = new THREE.SphereGeometry(1, 16, 16, 1);\n private static DebugMaterial = new THREE.MeshBasicMaterial({\n color: 0x00aa00,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n\n private debugMesh: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial> | null = null;\n\n constructor(private positionProbe: Interaction<ThreeJSGraphicsAdapter>) {\n super(positionProbe);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setRange(): void {\n this.updateDebugVisualisation();\n }\n\n setInFocus(): void {\n // no-op\n }\n\n setLineOfSight(): void {\n // no-op\n }\n\n setPriority(): void {\n // no-op\n }\n\n setPrompt(): void {\n // no-op\n }\n\n setDebug() {\n this.updateDebugVisualisation();\n }\n\n private clearDebugVisualisation() {\n if (this.debugMesh) {\n this.debugMesh.removeFromParent();\n this.debugMesh = null;\n }\n }\n\n private updateDebugVisualisation() {\n if (!this.positionProbe.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (this.positionProbe.isConnected && !this.debugMesh) {\n const mesh = new THREE.Mesh(\n ThreeJSInteraction.DebugGeometry,\n ThreeJSInteraction.DebugMaterial,\n );\n mesh.castShadow = false;\n mesh.receiveShadow = false;\n this.debugMesh = mesh;\n this.positionProbe.getContainer().add(this.debugMesh);\n }\n\n if (this.debugMesh) {\n this.debugMesh.scale.set(\n this.positionProbe.props.range,\n this.positionProbe.props.range,\n this.positionProbe.props.range,\n );\n }\n }\n }\n\n dispose() {\n this.clearDebugVisualisation();\n }\n}\n", "import { CanvasText, Label, LabelGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSLabel extends LabelGraphics<ThreeJSGraphicsAdapter> {\n static labelGeometry = new THREE.PlaneGeometry(1, 1);\n private mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial | null = null;\n private canvasText: CanvasText = new CanvasText();\n\n constructor(private label: Label<ThreeJSGraphicsAdapter>) {\n super(label);\n\n this.material = new THREE.MeshStandardMaterial({\n transparent: false,\n });\n this.mesh = new THREE.Mesh(ThreeJSLabel.labelGeometry, this.material);\n this.mesh.material = this.material;\n this.mesh.scale.x = this.label.props.width;\n this.mesh.scale.y = this.label.props.height;\n this.mesh.castShadow = this.label.props.castShadows;\n this.mesh.receiveShadow = true;\n this.redrawText();\n this.label.getContainer().add(this.mesh);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n setContent(): void {\n this.redrawText();\n }\n\n setAlignment(): void {\n this.redrawText();\n }\n\n setFontSize(): void {\n this.redrawText();\n }\n\n setPadding(): void {\n this.redrawText();\n }\n\n setFontColor(): void {\n this.redrawText();\n }\n\n setEmissive(): void {\n this.updateMaterialEmissiveIntensity();\n }\n\n setColor(): void {\n this.redrawText();\n }\n\n setWidth(width: number): void {\n this.mesh.scale.x = width;\n this.redrawText();\n }\n\n setHeight(height: number): void {\n this.mesh.scale.y = height;\n this.redrawText();\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n private redrawText() {\n if (!this.material) {\n return;\n }\n if (this.material.map) {\n this.material.map.dispose();\n }\n\n const canvas = this.canvasText.renderText(this.label.props.content, {\n bold: true,\n fontSize: this.label.props.fontSize * 2,\n paddingPx: this.label.props.padding,\n textColorRGB255A1: {\n r: this.label.props.fontColor.r * 255,\n g: this.label.props.fontColor.g * 255,\n b: this.label.props.fontColor.b * 255,\n a: this.label.props.fontColor.a ?? 1,\n },\n backgroundColorRGB255A1: {\n r: this.label.props.color.r * 255,\n g: this.label.props.color.g * 255,\n b: this.label.props.color.b * 255,\n a: this.label.props.color.a ?? 1,\n },\n dimensions: {\n width: this.label.props.width * 200,\n height: this.label.props.height * 200,\n },\n alignment: this.label.props.alignment,\n });\n\n this.material.map = new THREE.CanvasTexture(canvas);\n this.material.transparent = (this.label.props.color.a ?? 1) < 1;\n this.updateMaterialEmissiveIntensity();\n }\n\n private updateMaterialEmissiveIntensity() {\n if (this.material) {\n const map = this.material.map as THREE.Texture;\n if (this.label.props.emissive > 0) {\n this.material.emissive = new THREE.Color(0xffffff);\n this.material.emissiveMap = map;\n this.material.emissiveIntensity = this.label.props.emissive;\n this.material.needsUpdate = true;\n } else {\n this.material.emissive = new THREE.Color(0x000000);\n this.material.emissiveMap = null;\n this.material.emissiveIntensity = 1;\n this.material.needsUpdate = true;\n }\n }\n }\n\n dispose() {\n this.mesh.geometry.dispose();\n if (this.material) {\n if (this.material.map) {\n this.material.map.dispose();\n }\n this.material.dispose();\n this.material = null;\n }\n }\n}\n", "import { Light, LightTypes } from \"@mml-io/mml-web\";\nimport { LightGraphics } from \"@mml-io/mml-web\";\nimport { MMLColor } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\ndeclare type LightHelper = THREE.PointLightHelper | THREE.SpotLightHelper;\n\nconst debugSphereSize = 0.25;\n\nexport class ThreeJSLight extends LightGraphics<ThreeJSGraphicsAdapter> {\n private threeLight: THREE.PointLight | THREE.SpotLight;\n private threeLightHelper: LightHelper | null;\n\n constructor(private light: Light<ThreeJSGraphicsAdapter>) {\n super(light);\n this.createLight();\n }\n\n private createLight() {\n if (this.threeLight) {\n this.threeLight.removeFromParent();\n }\n\n const { r, g, b } = this.light.props.color;\n const color = new THREE.Color(r, g, b);\n\n switch (this.light.props.type) {\n case LightTypes.spotlight: {\n const light = new THREE.SpotLight(\n color,\n this.light.props.intensity,\n this.light.props.distance ?? undefined,\n THREE.MathUtils.degToRad(this.light.props.angleDeg),\n );\n // create a target\n const target = new THREE.Object3D();\n target.position.set(0, -1, 0);\n light.position.set(0, 0, 0);\n light.add(target);\n light.target = target;\n this.threeLight = light;\n break;\n }\n case LightTypes.point:\n this.threeLight = new THREE.PointLight(\n color,\n this.light.props.intensity,\n this.light.props.distance ?? undefined,\n );\n break;\n }\n\n if (this.threeLight.shadow) {\n this.threeLight.castShadow = this.light.props.castShadows;\n this.threeLight.shadow.mapSize.width = 512;\n this.threeLight.shadow.mapSize.height = 512;\n if (this.threeLight.shadow.camera.isPerspectiveCamera) {\n this.threeLight.shadow.camera.near = 0.5;\n this.threeLight.shadow.camera.far = 500;\n }\n this.threeLight.shadow.bias = -0.001;\n this.threeLight.shadow.normalBias = 0.01;\n const d = 10;\n const c = this.threeLight.shadow.camera as any;\n c.left = -d;\n c.right = d;\n c.top = d;\n c.bottom = -d;\n }\n\n this.threeLight.intensity = this.light.props.intensity;\n\n this.light.getContainer().add(this.threeLight);\n\n if (this.threeLightHelper) {\n this.makeLightHelper();\n }\n if (!this.light.props.enabled) {\n this.threeLight.visible = false;\n if (this.threeLightHelper) {\n this.threeLightHelper.visible = false;\n }\n }\n }\n\n private makeLightHelper() {\n if (this.threeLightHelper) {\n this.threeLightHelper.removeFromParent();\n this.threeLightHelper = null;\n }\n\n if (this.light instanceof THREE.PointLight) {\n this.threeLightHelper = new THREE.PointLightHelper(this.light, debugSphereSize);\n } else if (this.light instanceof THREE.SpotLight) {\n this.threeLightHelper = new THREE.SpotLightHelper(this.light);\n }\n\n if (this.threeLightHelper) {\n this.light.getContainer().add(this.threeLightHelper);\n this.threeLightHelper.matrix = this.threeLight.matrix;\n this.threeLightHelper.visible = this.threeLight.visible;\n }\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setEnabled(enabled: boolean): void {\n this.threeLight.visible = enabled;\n if (this.threeLightHelper) {\n this.threeLightHelper.visible = enabled;\n }\n }\n\n setCastShadows(castShadows: boolean) {\n this.threeLight.castShadow = castShadows;\n }\n\n setAngle(angle: number) {\n if ((this.threeLight as THREE.SpotLight).isSpotLight) {\n (this.threeLight as THREE.SpotLight).angle = THREE.MathUtils.degToRad(angle);\n }\n }\n\n setIntensity(intensity: number) {\n this.threeLight.intensity = intensity;\n }\n\n setDistance(distance: number) {\n this.threeLight.distance = distance;\n }\n\n setType(): void {\n this.createLight();\n }\n\n setDebug(debug: boolean): void {\n if (debug && !this.threeLightHelper) {\n this.makeLightHelper();\n } else if (!debug && this.threeLightHelper) {\n this.threeLightHelper.removeFromParent();\n this.threeLightHelper = null;\n }\n }\n\n setColor(color: MMLColor): void {\n this.threeLight.color.set(new THREE.Color(color.r, color.g, color.b));\n if (this.threeLightHelper) {\n this.threeLightHelper.color = new THREE.Color(color.r, color.g, color.b);\n }\n }\n\n dispose() {\n this.light.getContainer().remove(this.threeLight);\n if (this.threeLightHelper) {\n this.threeLightHelper.removeFromParent();\n }\n }\n}\n", "import { Link } from \"@mml-io/mml-web\";\nimport { LinkGraphics } from \"@mml-io/mml-web\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSLink extends LinkGraphics<ThreeJSGraphicsAdapter> {\n constructor(private link: Link<ThreeJSGraphicsAdapter>) {\n super(link);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setHref(): void {\n // no-op\n }\n\n setTarget(): void {\n // no-op\n }\n\n dispose() {}\n}\n", "import { MElement, MELEMENT_PROPERTY_NAME } from \"@mml-io/mml-web\";\nimport { MElementGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSMElement extends MElementGraphics<ThreeJSGraphicsAdapter> {\n protected container: THREE.Object3D;\n private currentParentContainer: THREE.Object3D | null = null;\n\n constructor(private element: MElement<ThreeJSGraphicsAdapter>) {\n super(element);\n this.container = new THREE.Group();\n this.container.name = this.constructor.name;\n (this.container as any)[MELEMENT_PROPERTY_NAME] = element;\n\n if (this.currentParentContainer !== null) {\n throw new Error(\"Already connected to a parent\");\n }\n\n const mElementParent = this.element.getMElementParent();\n if (mElementParent) {\n this.currentParentContainer = mElementParent.getContainer();\n this.currentParentContainer.add(this.container);\n return;\n }\n\n // If none of the ancestors are MElements then this element may be directly connected to the body (without a wrapper).\n // Attempt to use a global scene that has been configured to attach this element to.\n const scene = this.element.getScene();\n this.currentParentContainer = scene.getGraphicsAdapter().getRootContainer();\n this.currentParentContainer.add(this.container);\n }\n\n public getContainer(): THREE.Object3D {\n return this.container;\n }\n\n public dispose() {\n if (this.currentParentContainer === null) {\n throw new Error(\"Was not connected to a parent\");\n }\n\n this.currentParentContainer.remove(this.container);\n this.currentParentContainer = null;\n }\n}\n", "import { MElement, Model, TransformableElement } from \"@mml-io/mml-web\";\nimport { ModelGraphics } from \"@mml-io/mml-web\";\nimport { LoadingInstanceManager } from \"@mml-io/mml-web\";\nimport { IVect3 } from \"@mml-io/mml-web\";\nimport { ModelLoader, ModelLoadResult } from \"@mml-io/model-loader\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\ntype ThreeJSModelLoadState = {\n group: THREE.Object3D;\n bones: Map<string, THREE.Bone>;\n boundingBox: {\n size: THREE.Vector3;\n centerOffset: THREE.Vector3;\n };\n};\n\ntype ThreeJSModelAnimState = {\n currentAnimationClip: THREE.AnimationClip;\n appliedAnimation: {\n animationGroup: THREE.AnimationObjectGroup;\n animationMixer: THREE.AnimationMixer;\n animationAction: THREE.AnimationAction;\n } | null;\n};\n\nexport class ThreeJSModel extends ModelGraphics<ThreeJSGraphicsAdapter> {\n private static modelLoader = new ModelLoader();\n private srcLoadingInstanceManager = new LoadingInstanceManager(`${Model.tagName}.src`);\n private animLoadingInstanceManager = new LoadingInstanceManager(`${Model.tagName}.anim`);\n private latestSrcModelPromise: Promise<ModelLoadResult> | null = null;\n private latestAnimPromise: Promise<ModelLoadResult> | null = null;\n\n private socketChildrenByBone = new Map<string, Set<MElement<ThreeJSGraphicsAdapter>>>();\n\n private attachments = new Map<\n Model<ThreeJSGraphicsAdapter>,\n {\n animationGroup: THREE.AnimationObjectGroup;\n animationMixer: THREE.AnimationMixer;\n animationAction: THREE.AnimationAction;\n } | null\n >();\n private registeredParentAttachment: Model<ThreeJSGraphicsAdapter> | null = null;\n\n private static DebugBoundingBoxGeometry = new THREE.BoxGeometry(1, 1, 1, 1, 1, 1);\n private static DebugBoundingBoxMaterial = new THREE.MeshBasicMaterial({\n color: 0xff0000,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n private debugBoundingBox: THREE.Mesh | null = null;\n\n protected loadedState: ThreeJSModelLoadState | null = null;\n protected animState: ThreeJSModelAnimState | null = null;\n\n private documentTimeTickListener: null | { remove: () => void } = null;\n\n constructor(\n private model: Model<ThreeJSGraphicsAdapter>,\n private updateMeshCallback: () => void,\n ) {\n super(model, updateMeshCallback);\n }\n\n hasLoadedModel(): boolean {\n return !!this.loadedState?.group;\n }\n\n hasLoadedAnimation(): boolean {\n return !!this.animState?.appliedAnimation;\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getBoundingBox(): { centerOffset: IVect3; size: IVect3 } | null {\n if (this.loadedState) {\n return {\n centerOffset: this.loadedState.boundingBox.centerOffset,\n size: this.loadedState.boundingBox.size,\n };\n }\n return null;\n }\n\n getCollisionElement(): THREE.Object3D<THREE.Object3DEventMap> {\n return this.loadedState?.group ?? new THREE.Object3D();\n }\n\n setDebug(): void {\n this.updateDebugVisualisation();\n }\n\n setCastShadows(castShadows: boolean) {\n if (this.loadedState) {\n this.loadedState.group.traverse((object) => {\n if ((object as THREE.Mesh).isMesh) {\n const mesh = object as THREE.Mesh;\n mesh.castShadow = castShadows;\n }\n });\n }\n }\n\n setAnim(anim: string): void {\n this.resetAnimationMixer();\n this.animState = null;\n for (const [attachment, animState] of this.attachments) {\n if (animState) {\n animState.animationMixer.stopAllAction();\n this.attachments.set(attachment, null);\n }\n }\n\n if (!anim) {\n this.latestAnimPromise = null;\n this.animLoadingInstanceManager.abortIfLoading();\n\n // If the animation is removed then the model can be added to the parent attachment if the model is loaded\n if (this.loadedState && !this.registeredParentAttachment) {\n const parent = this.model.parentElement;\n if (parent && Model.isModel(parent)) {\n this.registeredParentAttachment = parent as Model<ThreeJSGraphicsAdapter>;\n (parent.modelGraphics as ThreeJSModel).registerAttachment(this.model);\n }\n }\n return;\n }\n\n if (this.registeredParentAttachment) {\n (this.registeredParentAttachment.modelGraphics as ThreeJSModel).unregisterAttachment(\n this.model,\n );\n this.registeredParentAttachment = null;\n }\n\n const animSrc = this.model.contentSrcToContentAddress(anim);\n const animPromise = this.asyncLoadSourceAsset(animSrc, (loaded, total) => {\n this.animLoadingInstanceManager.setProgress(loaded / total);\n });\n this.animLoadingInstanceManager.start(this.model.getLoadingProgressManager(), animSrc);\n this.latestAnimPromise = animPromise;\n animPromise\n .then((result) => {\n if (this.latestAnimPromise !== animPromise || !this.model.isConnected) {\n return;\n }\n this.latestAnimPromise = null;\n this.playAnimation(result.animations[0]);\n\n for (const [model] of this.attachments) {\n this.registerAttachment(model);\n }\n\n this.animLoadingInstanceManager.finish();\n })\n .catch((err) => {\n console.error(\"Error loading m-model.anim\", err);\n this.latestAnimPromise = null;\n this.animLoadingInstanceManager.error(err);\n });\n }\n\n setAnimEnabled(): void {\n // no-op - property is observed in animation tick\n }\n\n setAnimLoop(): void {\n // no-op - property is observed in animation tick\n }\n\n setAnimStartTime(): void {\n // no-op - property is observed in animation tick\n }\n\n setAnimPauseTime(): void {\n // no-op - property is observed in animation tick\n }\n\n transformed(): void {\n // no-op\n }\n\n setSrc(src: string): void {\n if (this.loadedState !== null) {\n this.loadedState.group.removeFromParent();\n if (this.registeredParentAttachment) {\n (this.registeredParentAttachment.modelGraphics as ThreeJSModel).unregisterAttachment(\n this.model,\n );\n this.registeredParentAttachment = null;\n }\n ThreeJSModel.disposeOfGroup(this.loadedState.group);\n this.loadedState = null;\n this.updateMeshCallback();\n this.updateDebugVisualisation();\n }\n if (!src) {\n this.srcLoadingInstanceManager.abortIfLoading();\n this.socketChildrenByBone.forEach((children) => {\n children.forEach((child) => {\n this.model.getContainer().add(child.getContainer());\n });\n });\n this.updateMeshCallback();\n this.updateDebugVisualisation();\n return;\n }\n\n const contentSrc = this.model.contentSrcToContentAddress(src);\n const srcModelPromise = this.asyncLoadSourceAsset(contentSrc, (loaded, total) => {\n this.srcLoadingInstanceManager.setProgress(loaded / total);\n });\n this.srcLoadingInstanceManager.start(this.model.getLoadingProgressManager(), contentSrc);\n this.latestSrcModelPromise = srcModelPromise;\n srcModelPromise\n .then((result) => {\n if (this.latestSrcModelPromise !== srcModelPromise || !this.model.isConnected) {\n // If we've loaded a different model since, or we're no longer connected, dispose of this one\n ThreeJSModel.disposeOfGroup(result.group);\n return;\n }\n result.group.traverse((child) => {\n if ((child as THREE.Mesh).isMesh) {\n child.castShadow = this.model.props.castShadows;\n child.receiveShadow = true;\n }\n });\n this.latestSrcModelPromise = null;\n const group = result.group;\n const bones = new Map<string, THREE.Bone>();\n group.traverse((object) => {\n if (object instanceof THREE.Bone) {\n bones.set(object.name, object);\n }\n });\n const boundingBox = new THREE.Box3();\n group.updateWorldMatrix(true, true);\n boundingBox.expandByObject(group);\n\n this.loadedState = {\n group,\n bones,\n boundingBox: {\n size: boundingBox.getSize(new THREE.Vector3(0, 0, 0)),\n centerOffset: boundingBox.getCenter(new THREE.Vector3(0, 0, 0)),\n },\n };\n this.model.getContainer().add(group);\n\n for (const [boneName, children] of this.socketChildrenByBone) {\n const bone = bones.get(boneName);\n if (bone) {\n children.forEach((child) => {\n bone.add(child.getContainer());\n });\n }\n }\n\n this.updateMeshCallback();\n\n const parent = this.model.parentElement;\n if (parent && Model.isModel(parent)) {\n if (!this.latestAnimPromise && !this.animState) {\n this.registeredParentAttachment = parent as Model<ThreeJSGraphicsAdapter>;\n (parent.modelGraphics as ThreeJSModel).registerAttachment(this.model);\n }\n }\n\n if (this.animState) {\n this.playAnimation(this.animState.currentAnimationClip);\n }\n this.srcLoadingInstanceManager.finish();\n\n this.updateDebugVisualisation();\n })\n .catch((err) => {\n console.error(\"Error loading m-model.src\", err);\n this.srcLoadingInstanceManager.error(err);\n });\n }\n\n public registerAttachment(attachment: Model<ThreeJSGraphicsAdapter>) {\n let animState = null;\n if (this.animState) {\n const attachmentLoadedState = (attachment.modelGraphics as ThreeJSModel).loadedState;\n if (!attachmentLoadedState) {\n throw new Error(\"Attachment must be loaded before registering\");\n }\n const animationGroup = new THREE.AnimationObjectGroup();\n const animationMixer = new THREE.AnimationMixer(animationGroup);\n const action = animationMixer.clipAction(this.animState.currentAnimationClip);\n animState = {\n animationGroup,\n animationMixer,\n animationAction: action,\n };\n animationGroup.add(attachmentLoadedState.group);\n action.play();\n }\n this.attachments.set(attachment, animState);\n }\n\n public unregisterAttachment(attachment: Model<ThreeJSGraphicsAdapter>) {\n const attachmentState = this.attachments.get(attachment);\n if (attachmentState) {\n attachmentState.animationMixer.stopAllAction();\n }\n this.attachments.delete(attachment);\n }\n\n private updateDebugVisualisation() {\n if (!this.model.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (!this.debugBoundingBox) {\n this.debugBoundingBox = new THREE.Mesh(\n ThreeJSModel.DebugBoundingBoxGeometry,\n ThreeJSModel.DebugBoundingBoxMaterial,\n );\n this.model.getContainer().add(this.debugBoundingBox);\n }\n if (this.loadedState) {\n const boundingBox = this.loadedState.boundingBox;\n if (boundingBox.centerOffset) {\n this.debugBoundingBox.position.copy(boundingBox.centerOffset);\n } else {\n this.debugBoundingBox.position.set(0, 0, 0);\n }\n this.debugBoundingBox.scale.copy(boundingBox.size);\n } else {\n this.debugBoundingBox.scale.set(0, 0, 0);\n }\n }\n }\n\n private clearDebugVisualisation() {\n if (this.debugBoundingBox) {\n this.debugBoundingBox.removeFromParent();\n this.debugBoundingBox = null;\n }\n }\n\n async asyncLoadSourceAsset(\n url: string,\n onProgress: (loaded: number, total: number) => void,\n ): Promise<ModelLoadResult> {\n return await ThreeJSModel.modelLoader.load(url, onProgress);\n }\n\n private resetAnimationMixer() {\n if (this.documentTimeTickListener) {\n this.documentTimeTickListener.remove();\n this.documentTimeTickListener = null;\n }\n if (this.animState) {\n const appliedAnimation = this.animState.appliedAnimation;\n if (appliedAnimation) {\n appliedAnimation.animationMixer.stopAllAction();\n }\n this.animState.appliedAnimation = null;\n }\n }\n\n public registerSocketChild(\n child: TransformableElement<ThreeJSGraphicsAdapter>,\n socketName: string,\n ): void {\n let children = this.socketChildrenByBone.get(socketName);\n if (!children) {\n children = new Set<MElement<ThreeJSGraphicsAdapter>>();\n this.socketChildrenByBone.set(socketName, children);\n }\n children.add(child);\n\n if (this.loadedState) {\n const bone = this.loadedState.bones.get(socketName);\n if (bone) {\n bone.add(child.getContainer());\n } else {\n this.model.getContainer().add(child.getContainer());\n }\n }\n }\n\n public unregisterSocketChild(\n child: TransformableElement<ThreeJSGraphicsAdapter>,\n socketName: string,\n addToRoot: boolean = true,\n ): void {\n const socketChildren = this.socketChildrenByBone.get(socketName);\n if (socketChildren) {\n socketChildren.delete(child);\n if (addToRoot) {\n this.model.getContainer().add(child.getContainer());\n }\n if (socketChildren.size === 0) {\n this.socketChildrenByBone.delete(socketName);\n }\n }\n }\n\n private triggerSocketedChildrenTransformed() {\n // Socketed children need to be updated when the animation is updated as their position may have updated\n this.socketChildrenByBone.forEach((children) => {\n children.forEach((child) => {\n if (TransformableElement.isTransformableElement(child)) {\n child.didUpdateTransformation();\n }\n });\n });\n }\n\n private playAnimation(anim: THREE.AnimationClip) {\n this.resetAnimationMixer();\n this.animState = {\n currentAnimationClip: anim,\n appliedAnimation: null,\n };\n const animationGroup = new THREE.AnimationObjectGroup();\n const animationMixer = new THREE.AnimationMixer(animationGroup);\n const action = animationMixer.clipAction(anim);\n this.animState.appliedAnimation = {\n animationGroup,\n animationMixer,\n animationAction: action,\n };\n if (this.loadedState) {\n animationGroup.add(this.loadedState.group);\n }\n action.play();\n if (!this.documentTimeTickListener) {\n this.documentTimeTickListener = this.model.addDocumentTimeTickListener(\n (documentTime: number) => {\n this.updateAnimation(documentTime);\n },\n );\n }\n }\n\n private updateAnimation(docTimeMs: number, force: boolean = false) {\n if (this.animState) {\n if (!this.model.props.animEnabled && this.animState.appliedAnimation) {\n this.resetAnimationMixer();\n this.triggerSocketedChildrenTransformed();\n } else {\n if (!this.animState.appliedAnimation) {\n this.playAnimation(this.animState.currentAnimationClip);\n }\n let animationTimeMs = docTimeMs - this.model.props.animStartTime;\n if (docTimeMs < this.model.props.animStartTime) {\n animationTimeMs = 0;\n } else if (this.model.props.animPauseTime !== null) {\n if (docTimeMs > this.model.props.animPauseTime) {\n animationTimeMs = this.model.props.animPauseTime - this.model.props.animStartTime;\n }\n }\n\n const clip = this.animState.currentAnimationClip;\n if (clip !== null) {\n if (!this.model.props.animLoop) {\n if (animationTimeMs > clip.duration * 1000) {\n animationTimeMs = clip.duration * 1000;\n }\n }\n }\n\n for (const [model, attachmentState] of this.attachments) {\n if (attachmentState) {\n attachmentState.animationMixer.setTime(animationTimeMs / 1000);\n (model.modelGraphics as ThreeJSModel).triggerSocketedChildrenTransformed();\n }\n }\n\n if (force) {\n this.animState.appliedAnimation?.animationMixer.setTime((animationTimeMs + 1) / 1000);\n }\n this.animState.appliedAnimation?.animationMixer.setTime(animationTimeMs / 1000);\n this.triggerSocketedChildrenTransformed();\n }\n }\n }\n\n dispose() {\n if (this.documentTimeTickListener) {\n this.documentTimeTickListener.remove();\n this.documentTimeTickListener = null;\n }\n if (this.registeredParentAttachment) {\n (this.registeredParentAttachment?.modelGraphics as ThreeJSModel)?.unregisterAttachment(\n this.model,\n );\n this.registeredParentAttachment = null;\n }\n if (this.loadedState) {\n this.loadedState.group.removeFromParent();\n ThreeJSModel.disposeOfGroup(this.loadedState.group);\n this.loadedState = null;\n }\n this.clearDebugVisualisation();\n this.animLoadingInstanceManager.dispose();\n this.srcLoadingInstanceManager.dispose();\n }\n\n private static disposeOfGroup(group: THREE.Object3D) {\n group.traverse((child) => {\n if ((child as THREE.Mesh).isMesh) {\n const mesh = child as THREE.Mesh;\n mesh.geometry.dispose();\n if (Array.isArray(mesh.material)) {\n for (const material of mesh.material) {\n ThreeJSModel.disposeOfMaterial(material);\n }\n } else if (mesh.material) {\n ThreeJSModel.disposeOfMaterial(mesh.material);\n }\n }\n });\n }\n\n private static disposeOfMaterial(material: THREE.Material) {\n material.dispose();\n for (const key of Object.keys(material)) {\n const value = (material as any)[key];\n if (value && typeof value === \"object\" && \"minFilter\" in value) {\n value.dispose();\n }\n }\n }\n}\n", "import { Plane } from \"@mml-io/mml-web\";\nimport { MMLColor } from \"@mml-io/mml-web\";\nimport { PlaneGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSPlane extends PlaneGraphics<ThreeJSGraphicsAdapter> {\n static planeGeometry = new THREE.PlaneGeometry(1, 1);\n private mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial;\n\n constructor(private plane: Plane<ThreeJSGraphicsAdapter>) {\n super(plane);\n\n this.material = new THREE.MeshStandardMaterial({\n color: new THREE.Color(plane.props.color.r, plane.props.color.g, plane.props.color.b),\n });\n this.mesh = new THREE.Mesh(ThreeJSPlane.planeGeometry, this.material);\n this.mesh.castShadow = plane.props.castShadows;\n this.mesh.receiveShadow = true;\n this.plane.getContainer().add(this.mesh);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n setColor(color: MMLColor): void {\n this.material.color = new THREE.Color(color.r, color.g, color.b);\n }\n\n setWidth(width: number): void {\n this.mesh.scale.x = width;\n }\n\n setHeight(height: number): void {\n this.mesh.scale.y = height;\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n setOpacity(opacity: number): void {\n const needsUpdate = this.material.transparent === (opacity === 1);\n this.material.transparent = opacity !== 1;\n this.material.needsUpdate = needsUpdate;\n this.material.opacity = opacity;\n }\n\n dispose() {}\n}\n", "import { PositionProbe } from \"@mml-io/mml-web\";\nimport { PositionProbeGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSPositionProbe extends PositionProbeGraphics<ThreeJSGraphicsAdapter> {\n private static DebugGeometry = new THREE.SphereGeometry(1, 16, 16, 1);\n private static DebugMaterial = new THREE.MeshBasicMaterial({\n color: 0xff0000,\n wireframe: true,\n transparent: true,\n opacity: 0.3,\n });\n\n private debugMesh: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial> | null = null;\n\n constructor(private positionProbe: PositionProbe<ThreeJSGraphicsAdapter>) {\n super(positionProbe);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setRange(): void {\n this.updateDebugVisualisation();\n }\n\n setDebug() {\n this.updateDebugVisualisation();\n }\n\n private clearDebugVisualisation() {\n if (this.debugMesh) {\n this.debugMesh.removeFromParent();\n this.debugMesh = null;\n }\n }\n\n private updateDebugVisualisation() {\n if (!this.positionProbe.props.debug) {\n this.clearDebugVisualisation();\n } else {\n if (this.positionProbe.isConnected && !this.debugMesh) {\n const mesh = new THREE.Mesh(\n ThreeJSPositionProbe.DebugGeometry,\n ThreeJSPositionProbe.DebugMaterial,\n );\n mesh.castShadow = false;\n mesh.receiveShadow = false;\n this.debugMesh = mesh;\n this.positionProbe.getContainer().add(this.debugMesh);\n }\n\n if (this.debugMesh) {\n this.debugMesh.scale.set(\n this.positionProbe.props.range,\n this.positionProbe.props.range,\n this.positionProbe.props.range,\n );\n }\n }\n }\n\n dispose() {\n this.clearDebugVisualisation();\n }\n}\n", "import { Prompt } from \"@mml-io/mml-web\";\nimport { PromptGraphics } from \"@mml-io/mml-web\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSPrompt extends PromptGraphics<ThreeJSGraphicsAdapter> {\n constructor(private prompt: Prompt<ThreeJSGraphicsAdapter>) {\n super(prompt);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n setMessage(): void {\n // no-op\n }\n\n setPlaceholder(): void {\n // no-op\n }\n\n setPrefill(): void {\n // no-op\n }\n\n setDebug(): void {\n // no-op\n }\n\n dispose() {}\n}\n", "import { RemoteDocument, RemoteDocumentGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\nimport { getThreeJSReconnectingStatus } from \"../ThreeJSReconnectingStatus\";\n\nexport class ThreeJSRemoteDocument extends RemoteDocumentGraphics<ThreeJSGraphicsAdapter> {\n private statusUI: THREE.Mesh | null = null;\n\n constructor(private element: RemoteDocument<ThreeJSGraphicsAdapter>) {\n super(element);\n }\n\n public showError(showError: boolean): void {\n if (!showError) {\n if (this.statusUI !== null) {\n this.element.getContainer().remove(this.statusUI);\n this.statusUI = null;\n }\n } else {\n if (this.statusUI === null) {\n const { geometry, material, height } = getThreeJSReconnectingStatus();\n const mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.MeshBasicMaterial> = new THREE.Mesh(\n geometry,\n material,\n );\n mesh.position.set(0, height / 2, 0);\n this.statusUI = mesh;\n this.element.getContainer().add(this.statusUI);\n }\n }\n }\n\n public dispose() {}\n}\n", "import { CanvasText } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nfunction createReconnectingStatus() {\n const canvas = new CanvasText().renderText(\"Reconnecting\", {\n bold: true,\n fontSize: 32,\n paddingPx: 10,\n textColorRGB255A1: {\n r: 255,\n g: 0,\n b: 0,\n a: 1.0,\n },\n backgroundColorRGB255A1: {\n r: 255,\n g: 255,\n b: 255,\n a: 1.0,\n },\n alignment: \"center\",\n });\n\n const texture = new THREE.Texture(canvas);\n texture.minFilter = THREE.LinearFilter;\n texture.magFilter = THREE.LinearFilter;\n texture.format = THREE.RGBAFormat;\n texture.needsUpdate = true;\n\n const width = canvas.width;\n const height = canvas.height;\n\n const material = new THREE.MeshBasicMaterial({\n map: texture,\n side: THREE.DoubleSide,\n });\n const geometry = new THREE.PlaneGeometry(width / 100, height / 100, 1, 1);\n return { geometry, material, width: width / 100, height: height / 100 };\n}\n\nexport type ThreeJSReconnectingStatus = {\n geometry: THREE.PlaneGeometry;\n material: THREE.MeshBasicMaterial;\n width: number;\n height: number;\n};\n\nlet reconnectingStatus: ThreeJSReconnectingStatus | null = null;\n\nexport function getThreeJSReconnectingStatus(): ThreeJSReconnectingStatus {\n if (!reconnectingStatus) {\n reconnectingStatus = createReconnectingStatus();\n }\n return reconnectingStatus;\n}\n", "import { Sphere } from \"@mml-io/mml-web\";\nimport { MMLColor } from \"@mml-io/mml-web\";\nimport { SphereGraphics } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nconst defaultSphereWidthSegments = 16;\nconst defaultSphereHeightSegments = 16;\n\nexport class ThreeJSSphere extends SphereGraphics<ThreeJSGraphicsAdapter> {\n static sphereGeometry = new THREE.SphereGeometry(\n 0.5,\n defaultSphereWidthSegments,\n defaultSphereHeightSegments,\n );\n private mesh: THREE.Mesh<THREE.SphereGeometry, THREE.Material | Array<THREE.Material>>;\n private material: THREE.MeshStandardMaterial;\n\n constructor(private sphere: Sphere<ThreeJSGraphicsAdapter>) {\n super(sphere);\n\n this.material = new THREE.MeshStandardMaterial({\n color: new THREE.Color(sphere.props.color.r, sphere.props.color.g, sphere.props.color.b),\n });\n this.mesh = new THREE.Mesh(ThreeJSSphere.sphereGeometry, this.material);\n this.mesh.castShadow = sphere.props.castShadows;\n this.mesh.receiveShadow = true;\n this.sphere.getContainer().add(this.mesh);\n }\n\n disable(): void {}\n\n enable(): void {}\n\n getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n setColor(color: MMLColor): void {\n this.material.color = new THREE.Color(color.r, color.g, color.b);\n }\n\n setRadius(radius: number): void {\n this.mesh.scale.x = radius * 2;\n this.mesh.scale.y = radius * 2;\n this.mesh.scale.z = radius * 2;\n }\n\n setCastShadows(castShadows: boolean): void {\n this.mesh.castShadow = castShadows;\n }\n\n setOpacity(opacity: number): void {\n const needsUpdate = this.material.transparent === (opacity === 1);\n this.material.transparent = opacity !== 1;\n this.material.needsUpdate = needsUpdate;\n this.material.opacity = opacity;\n }\n\n dispose() {}\n}\n", "import {\n Matr4,\n Matr4Data,\n Model,\n TransformableElement,\n TransformableGraphics,\n} from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\nimport { ThreeJSModel } from \"./ThreeJSModel\";\n\nexport class ThreeJSTransformable extends TransformableGraphics<ThreeJSGraphicsAdapter> {\n private socketName: string | null = null;\n private registeredSocketParent: ThreeJSModel | null = null;\n\n constructor(private transformableElement: TransformableElement<ThreeJSGraphicsAdapter>) {\n super(transformableElement);\n }\n\n getWorldMatrix(): Matr4 {\n // TODO - optimize/reduce calls to updateWorldMatrix\n const container = this.getContainer();\n container.updateWorldMatrix(true, false);\n return new Matr4(container.matrixWorld.elements as Matr4Data);\n }\n\n setVisible(visible: boolean): void {\n this.getContainer().visible = visible;\n }\n\n setSocket(socketName: string | null): void {\n if (this.socketName !== socketName) {\n if (this.socketName !== null && this.registeredSocketParent) {\n this.registeredSocketParent.unregisterSocketChild(\n this.transformableElement,\n this.socketName,\n );\n }\n this.socketName = socketName;\n if (socketName !== null) {\n this.registerWithParentModel(socketName);\n }\n } else {\n this.socketName = socketName;\n }\n }\n\n private registerWithParentModel(socketName: string): void {\n if (\n (this.transformableElement.parentElement as Model<ThreeJSGraphicsAdapter> | undefined)\n ?.isModel\n ) {\n const parentModel = this.transformableElement.parentElement as Model<ThreeJSGraphicsAdapter>;\n this.registeredSocketParent = parentModel.modelGraphics as ThreeJSModel;\n this.registeredSocketParent.registerSocketChild(this.transformableElement, socketName);\n }\n }\n\n private getContainer(): THREE.Group {\n return this.transformableElement.getContainer() as THREE.Group;\n }\n\n setX(x: number): void {\n this.getContainer().position.x = x;\n }\n\n setY(y: number): void {\n this.getContainer().position.y = y;\n }\n\n setZ(z: number): void {\n this.getContainer().position.z = z;\n }\n\n setRotationX(rotationX: number): void {\n this.getContainer().rotation.x = rotationX * THREE.MathUtils.DEG2RAD;\n }\n\n setRotationY(rotationY: number): void {\n this.getContainer().rotation.y = rotationY * THREE.MathUtils.DEG2RAD;\n }\n\n setRotationZ(rotationZ: number): void {\n this.getContainer().rotation.z = rotationZ * THREE.MathUtils.DEG2RAD;\n }\n\n setScaleX(scaleX: number): void {\n this.getContainer().scale.x = scaleX;\n }\n\n setScaleY(scaleY: number): void {\n this.getContainer().scale.y = scaleY;\n }\n\n setScaleZ(scaleZ: number): void {\n this.getContainer().scale.z = scaleZ;\n }\n\n dispose() {\n if (this.socketName && this.registeredSocketParent !== null) {\n this.registeredSocketParent.unregisterSocketChild(\n this.transformableElement,\n this.socketName,\n false,\n );\n }\n }\n}\n", "import {\n calculateContentSize,\n StaticFileVideoSource,\n Video,\n VideoGraphics,\n VideoSource,\n WHEPVideoSource,\n} from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"../ThreeJSGraphicsAdapter\";\n\nconst audioRefDistance = 1;\nconst audioRolloffFactor = 1;\n\nconst disabledVideoMaterial = new THREE.MeshStandardMaterial({\n color: 0x000000,\n side: THREE.DoubleSide,\n});\n\nexport class ThreeJSVideo extends VideoGraphics<ThreeJSGraphicsAdapter> {\n private videoSource: VideoSource | null = null;\n private videoMaterial: THREE.MeshStandardMaterial;\n\n private mesh: THREE.Mesh<\n THREE.PlaneGeometry,\n THREE.MeshStandardMaterial | THREE.MeshBasicMaterial\n >;\n\n private loadedVideoState: {\n video: HTMLVideoElement;\n audio: THREE.PositionalAudio;\n videoTexture: THREE.VideoTexture | null;\n } | null = null;\n\n constructor(\n private video: Video<ThreeJSGraphicsAdapter>,\n private updateMeshCallback: () => void,\n ) {\n super(video, updateMeshCallback);\n\n const geometry = new THREE.PlaneGeometry(1, 1, 1, 1);\n // Video material is only applied once a video is played\n this.videoMaterial = new THREE.MeshStandardMaterial({\n color: 0xffffff,\n transparent: false,\n side: THREE.DoubleSide,\n });\n this.mesh = new THREE.Mesh(geometry, disabledVideoMaterial);\n this.mesh.castShadow = true;\n this.mesh.receiveShadow = false;\n this.video.getContainer().add(this.mesh);\n }\n\n public getWidthAndHeight(): { width: number; height: number } {\n return {\n width: this.mesh.scale.x,\n height: this.mesh.scale.y,\n };\n }\n\n public syncVideoTime() {\n if (this.loadedVideoState) {\n const videoTag = this.loadedVideoState.video;\n if (videoTag.readyState === 0) {\n return;\n }\n\n const audioListener = this.getAudioListener();\n const audioContext = audioListener.context;\n if (audioContext.state === \"running\") {\n videoTag.muted = false;\n }\n\n if (this.video.isDisabled()) {\n videoTag.muted = true;\n }\n\n if (this.videoSource) {\n this.videoSource.syncVideoSource(this.video.props);\n }\n }\n }\n\n private getAudioListener() {\n return this.video.getScene().getGraphicsAdapter().getAudioListener();\n }\n\n public enable(): void {\n this.updateVideo();\n }\n public disable(): void {\n this.updateVideo();\n }\n\n public getCollisionElement(): THREE.Object3D {\n return this.mesh;\n }\n\n public setSrc(): void {\n this.updateVideo();\n }\n\n public setWidth(): void {\n this.updateWidthAndHeight();\n }\n\n public setHeight(): void {\n this.updateWidthAndHeight();\n }\n\n public setEnabled(): void {\n this.updateVideo();\n }\n\n public setCastShadows(): void {\n this.updateVideo();\n }\n\n public setLoop(): void {\n this.updateVideo();\n }\n\n public setVolume(): void {\n if (this.loadedVideoState) {\n this.loadedVideoState.audio.setVolume(this.video.props.volume);\n }\n }\n\n public setEmissive(): void {\n this.updateVideo();\n this.updateMaterialEmissiveIntensity();\n }\n\n public setStartTime(): void {\n this.updateVideo();\n }\n\n public setPauseTime(): void {\n this.updateVideo();\n }\n\n private updateVideo() {\n if (!this.video.isConnected) {\n return;\n }\n\n if (!this.video.props.enabled) {\n this.clearSource();\n return;\n }\n\n if (!this.video.props.src) {\n this.clearSource();\n } else {\n const contentAddress = this.video.contentSrcToContentAddress(this.video.props.src);\n if (this.videoSource === null || this.videoSource.getContentAddress() !== contentAddress) {\n this.clearSource();\n\n const video = document.createElement(\"video\");\n video.playsInline = true;\n // Muted allows autoplay immediately without the user needing to interact with the document\n // Video will be unmuted when the audiocontext is available\n video.muted = true;\n video.autoplay = true;\n video.crossOrigin = \"anonymous\";\n\n const audioListener = this.getAudioListener();\n const audioContext = audioListener.context;\n\n const audio = new THREE.PositionalAudio(audioListener);\n audio.setMediaElementSource(video);\n audio.setVolume(this.video.props.volume);\n audio.setRefDistance(audioRefDistance);\n audio.setRolloffFactor(audioRolloffFactor);\n this.loadedVideoState = {\n video,\n audio,\n videoTexture: null,\n };\n this.updateMaterialEmissiveIntensity();\n this.video.getContainer().add(audio);\n\n const url = new URL(contentAddress);\n if (WHEPVideoSource.isWHEPURL(url)) {\n this.videoSource = new WHEPVideoSource(url, video);\n } else {\n this.videoSource = new StaticFileVideoSource(url, video, this.video.props, () => {\n return this.video.getDocumentTime();\n });\n }\n\n audioContext.addEventListener(\"statechange\", () => {\n this.syncVideoTime();\n });\n video.addEventListener(\"loadeddata\", () => {\n if (!this.loadedVideoState || this.loadedVideoState.video !== video) {\n // Video was changed before it loaded\n return;\n }\n\n const videoTexture = new THREE.VideoTexture(video);\n this.videoMaterial.map = videoTexture;\n this.videoMaterial.needsUpdate = true;\n this.mesh.material = this.videoMaterial;\n this.loadedVideoState.videoTexture = videoTexture;\n\n this.syncVideoTime();\n this.updateWidthAndHeight();\n this.updateMaterialEmissiveIntensity();\n });\n }\n }\n\n if (this.videoSource) {\n this.syncVideoTime();\n }\n }\n\n private clearSource() {\n if (this.videoSource) {\n this.videoSource.dispose();\n this.videoSource = null;\n }\n if (this.loadedVideoState) {\n const tag = this.loadedVideoState.video;\n // There is an existing src - stop playing to allow changing it\n tag.pause();\n tag.src = \"\";\n tag.load();\n this.loadedVideoState = null;\n this.mesh.material = disabledVideoMaterial;\n this.updateWidthAndHeight();\n }\n }\n\n dispose() {\n this.clearSource();\n if (this.loadedVideoState) {\n this.loadedVideoState = null;\n }\n }\n\n private updateMaterialEmissiveIntensity() {\n if (this.loadedVideoState && this.loadedVideoState.videoTexture) {\n if (this.video.props.emissive > 0) {\n this.videoMaterial.emissive = new THREE.Color(0xffffff);\n this.videoMaterial.emissiveMap = this.loadedVideoState.videoTexture;\n this.videoMaterial.emissiveIntensity = this.video.props.emissive;\n this.videoMaterial.needsUpdate = true;\n } else {\n this.videoMaterial.emissive = new THREE.Color(0x000000);\n this.videoMaterial.emissiveMap = null;\n this.videoMaterial.emissiveIntensity = 1;\n this.videoMaterial.needsUpdate = true;\n }\n }\n }\n\n private updateWidthAndHeight() {\n const mesh = this.mesh;\n\n const { width, height } = calculateContentSize({\n content: this.loadedVideoState\n ? {\n width: this.loadedVideoState.video.videoWidth,\n height: this.loadedVideoState.video.videoHeight,\n }\n : undefined,\n width: this.video.props.width,\n height: this.video.props.height,\n });\n mesh.scale.x = width;\n mesh.scale.y = height;\n\n this.updateMeshCallback();\n }\n}\n", "import {\n EventHandlerCollection,\n getRelativePositionAndRotationRelativeToObject,\n MElement,\n TransformableElement,\n} from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nconst mouseMovePixelsThreshold = 10;\nconst mouseMoveTimeThresholdMilliseconds = 500;\n\n/**\n * The ThreeJSClickTrigger class is responsible for handling click events on the MML scene and raycasts into the scene to\n * determine which object was clicked and then dispatches events to those elements.\n */\nexport class ThreeJSClickTrigger {\n private eventHandlerCollection: EventHandlerCollection = new EventHandlerCollection();\n private raycaster: THREE.Raycaster;\n private mouseDownTime: number | null = null;\n private mouseMoveDelta = 0;\n\n static init(\n clickTarget: Document | HTMLElement,\n rootContainer: THREE.Object3D,\n camera: THREE.Camera,\n ): ThreeJSClickTrigger {\n return new ThreeJSClickTrigger(clickTarget, rootContainer, camera);\n }\n\n private constructor(\n private clickTarget: Document | HTMLElement,\n private rootContainer: THREE.Object3D,\n private camera: THREE.Camera,\n ) {\n this.raycaster = new THREE.Raycaster();\n\n this.eventHandlerCollection.add(clickTarget, \"mousedown\", this.handleMouseDown.bind(this));\n this.eventHandlerCollection.add(clickTarget, \"mouseup\", this.handleMouseUp.bind(this));\n this.eventHandlerCollection.add(clickTarget, \"mousemove\", this.handleMouseMove.bind(this));\n }\n\n private handleMouseDown() {\n this.mouseDownTime = Date.now();\n this.mouseMoveDelta = 0;\n }\n\n private handleMouseUp(event: MouseEvent) {\n if (!this.mouseDownTime) {\n return;\n }\n const duration = Date.now() - this.mouseDownTime;\n this.mouseDownTime = null;\n if (\n this.mouseMoveDelta < mouseMovePixelsThreshold &&\n duration < mouseMoveTimeThresholdMilliseconds\n ) {\n this.handleClick(event);\n }\n }\n\n private handleMouseMove(event: MouseEvent) {\n if (this.mouseDownTime) {\n this.mouseMoveDelta += Math.abs(event.movementX) + Math.abs(event.movementY);\n }\n }\n\n private handleClick(event: MouseEvent) {\n if ((event.detail as any).element) {\n // Avoid infinite loop of handling click events that originated from this trigger\n return;\n }\n let x = 0;\n let y = 0;\n if (!document.pointerLockElement) {\n let width = window.innerWidth;\n let height = window.innerHeight;\n if (this.clickTarget instanceof HTMLElement) {\n width = this.clickTarget.offsetWidth;\n height = this.clickTarget.offsetHeight;\n }\n x = (event.offsetX / width) * 2 - 1;\n y = -((event.offsetY / height) * 2 - 1);\n }\n this.raycaster.setFromCamera(new THREE.Vector2(x, y), this.camera);\n const intersections = this.raycaster.intersectObject(this.rootContainer, true);\n if (intersections.length > 0) {\n for (const intersection of intersections) {\n let obj: THREE.Object3D | null = intersection.object;\n while (obj) {\n /*\n Ignore scene objects that have a transparent or wireframe material\n */\n if (this.isMaterialIgnored(obj)) {\n break;\n }\n\n const mElement = MElement.getMElementFromObject(obj);\n if (\n mElement &&\n TransformableElement.isTransformableElement(mElement) &&\n mElement.isClickable()\n ) {\n // let's get the intersection point relative to the element origin\n\n const elementRelative = getRelativePositionAndRotationRelativeToObject(\n {\n position: intersection.point,\n rotation: {\n x: 0,\n y: 0,\n z: 0,\n },\n },\n mElement,\n );\n\n mElement.dispatchEvent(\n new CustomEvent(\"click\", {\n bubbles: true,\n detail: {\n position: {\n ...elementRelative.position,\n },\n },\n }),\n );\n return;\n }\n obj = obj.parent;\n }\n }\n }\n }\n\n dispose() {\n this.eventHandlerCollection.clear();\n }\n\n private isMaterialIgnored(obj: THREE.Object3D): boolean {\n const mesh = obj as THREE.Mesh;\n if (mesh) {\n if (\n ((mesh.material as THREE.Material) &&\n (mesh.material as THREE.Material).transparent &&\n (mesh.material as THREE.Material).opacity < 1) ||\n ((mesh.material as THREE.MeshLambertMaterial) &&\n (mesh.material as THREE.MeshLambertMaterial).wireframe) ||\n ((mesh.material as THREE.MeshPhongMaterial) &&\n (mesh.material as THREE.MeshPhongMaterial).wireframe) ||\n ((mesh.material as THREE.MeshPhysicalMaterial) &&\n (mesh.material as THREE.MeshPhysicalMaterial).wireframe) ||\n ((mesh.material as THREE.MeshStandardMaterial) &&\n (mesh.material as THREE.MeshStandardMaterial).wireframe) ||\n ((mesh.material as THREE.LineBasicMaterial) &&\n (mesh.material as THREE.LineBasicMaterial).isLineBasicMaterial)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n", "import { MMLGraphicsInterface } from \"@mml-io/mml-web\";\n\nimport * as ThreeJSElements from \"./elements\";\nimport { ThreeJSGraphicsAdapter } from \"./ThreeJSGraphicsAdapter\";\n\nexport const ThreeJSGraphicsInterface: MMLGraphicsInterface<ThreeJSGraphicsAdapter> = {\n MElementGraphicsInterface: (element) => new ThreeJSElements.ThreeJSMElement(element),\n MMLDebugHelperGraphicsInterface: (debugHelper) =>\n new ThreeJSElements.ThreeJSDebugHelper(debugHelper),\n MMLAudioGraphicsInterface: (element) => new ThreeJSElements.ThreeJSAudio(element),\n MMLChatProbeGraphicsInterface: (element) => new ThreeJSElements.ThreeJSChatProbe(element),\n MMLCubeGraphicsInterface: (element) => new ThreeJSElements.ThreeJSCube(element),\n MMLCylinderGraphicsInterface: (element) => new ThreeJSElements.ThreeJSCylinder(element),\n MMLFrameGraphicsInterface: (element) => new ThreeJSElements.ThreeJSFrame(element),\n MMLImageGraphicsInterface: (element, updateMeshCallback) =>\n new ThreeJSElements.ThreeJSImage(element, updateMeshCallback),\n MMLInteractionGraphicsInterface: (element) => new ThreeJSElements.ThreeJSInteraction(element),\n MMLLabelGraphicsInterface: (element) => new ThreeJSElements.ThreeJSLabel(element),\n MMLLightGraphicsInterface: (element) => new ThreeJSElements.ThreeJSLight(element),\n MMLLinkGraphicsInterface: (element) => new ThreeJSElements.ThreeJSLink(element),\n MMLModelGraphicsInterface: (element, updateMeshCallback) =>\n new ThreeJSElements.ThreeJSModel(element, updateMeshCallback),\n MMLPlaneGraphicsInterface: (element) => new ThreeJSElements.ThreeJSPlane(element),\n MMLPositionProbeGraphicsInterface: (element) => new ThreeJSElements.ThreeJSPositionProbe(element),\n MMLPromptGraphicsInterface: (element) => new ThreeJSElements.ThreeJSPrompt(element),\n MMLSphereGraphicsInterface: (element) => new ThreeJSElements.ThreeJSSphere(element),\n MMLTransformableGraphicsInterface: (element) => new ThreeJSElements.ThreeJSTransformable(element),\n MMLVideoGraphicsInterface: (element, updateMeshCallback: () => void) =>\n new ThreeJSElements.ThreeJSVideo(element, updateMeshCallback),\n RemoteDocumentGraphicsInterface: (element) => new ThreeJSElements.ThreeJSRemoteDocument(element),\n};\n", "import { Interaction } from \"@mml-io/mml-web\";\nimport * as THREE from \"three\";\n\nimport { ThreeJSGraphicsAdapter } from \"./ThreeJSGraphicsAdapter\";\n\nexport class ThreeJSInteractionAdapter {\n private static worldPos = new THREE.Vector3();\n\n private static matrix = new THREE.Matrix4();\n private static frustum = new THREE.Frustum();\n\n private static raycaster = new THREE.Raycaster();\n private static intersections = new Array<THREE.Intersection<THREE.Object3D>>();\n private static direction = new THREE.Vector3();\n\n static interactionShouldShowDistance(\n interaction: Interaction<ThreeJSGraphicsAdapter>,\n camera: THREE.Camera,\n scene: THREE.Scene,\n ): number | null {\n const worldPos = interaction\n .getContainer()\n .getWorldPosition(ThreeJSInteractionAdapter.worldPos);\n\n const cameraPos = camera.position;\n const distance = cameraPos.distanceTo(worldPos);\n if (distance > interaction.props.range) {\n return null;\n }\n\n if (interaction.props.inFocus) {\n ThreeJSInteractionAdapter.matrix.multiplyMatrices(\n camera.projectionMatrix,\n camera.matrixWorldInverse,\n );\n ThreeJSInteractionAdapter.frustum.setFromProjectionMatrix(ThreeJSInteractionAdapter.matrix);\n if (!ThreeJSInteractionAdapter.frustum.containsPoint(worldPos)) {\n return null;\n }\n }\n\n if (interaction.props.lineOfSight) {\n const raycastResults = ThreeJSInteractionAdapter.getRaycastResults(\n cameraPos,\n worldPos,\n distance,\n scene,\n );\n if (raycastResults.length > 0) {\n for (const result of raycastResults) {\n if (!ThreeJSInteractionAdapter.hasAncestor(result.object, interaction.getContainer())) {\n return null;\n }\n }\n }\n }\n\n return distance;\n }\n\n static getRaycastResults(\n a: THREE.Vector3,\n b: THREE.Vector3,\n distance: number,\n scene: THREE.Scene,\n ) {\n ThreeJSInteractionAdapter.direction.copy(b);\n ThreeJSInteractionAdapter.direction.sub(a);\n ThreeJSInteractionAdapter.direction.normalize();\n\n ThreeJSInteractionAdapter.raycaster.set(a, ThreeJSInteractionAdapter.direction);\n ThreeJSInteractionAdapter.raycaster.near = 0;\n ThreeJSInteractionAdapter.raycaster.far = distance;\n\n ThreeJSInteractionAdapter.intersections.length = 0;\n ThreeJSInteractionAdapter.raycaster.intersectObject(\n scene,\n true,\n ThreeJSInteractionAdapter.intersections,\n );\n return ThreeJSInteractionAdapter.intersections;\n }\n\n static hasAncestor(object: THREE.Object3D, ancestor: THREE.Object3D): boolean {\n let parent = object.parent;\n while (parent !== null) {\n if (parent === ancestor) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n }\n}\n"],
5
+ "mappings": ";AAAA,SAAS,aAA0B;AACnC,SAAS,qBAAqB;AAC9B,SAAS,8BAA8B;AACvC,YAAY,WAAW;AACvB,SAAS,6BAA6B;AAItC,IAAM,uBAAuB;AAC7B,IAAM,qBAAqB,IAAU,qBAAe,sBAAsB,GAAG,CAAC;AAC9E,IAAM,qBAAqB,IAAU,wB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iB,2BAA0B;AAAA,QAC/C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,UAAI,eAAe,SAAS,GAAG;AAC7B,mBAAW,UAAU,gBAAgB;AACnC,cAAI,CAAC,2BAA0B,YAAY,OAAO,QAAQ,YAAY,aAAa,CAAC,GAAG;AACrF,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,kBACL,GACA,GACA,UACA,OACA;AACA,+BAA0B,UAAU,KAAK,CAAC;AAC1C,+BAA0B,UAAU,IAAI,CAAC;AACzC,+BAA0B,UAAU,UAAU;AAE9C,+BAA0B,UAAU,IAAI,GAAG,2BAA0B,SAAS;AAC9E,+BAA0B,UAAU,OAAO;AAC3C,+BAA0B,UAAU,MAAM;AAE1C,+BAA0B,cAAc,SAAS;AACjD,+BAA0B,UAAU;AAAA,MAClC;AAAA,MACA;AAAA,MACA,2BAA0B;AAAA,IAC5B;AACA,WAAO,2BAA0B;AAAA,EACnC;AAAA,EAEA,OAAO,YAAY,QAAwB,UAAmC;AAC5E,QAAI,SAAS,OAAO;AACpB,WAAO,WAAW,MAAM;AACtB,UAAI,WAAW,UAAU;AACvB,eAAO;AAAA,MACT;AACA,eAAS,OAAO;AAAA,IAClB;AACA,WAAO;AAAA,EACT;AACF;AAxFa,2BACI,WAAW,IAAU,gBAAQ;AADjC,2BAGI,SAAS,IAAU,gBAAQ;AAH/B,2BAII,UAAU,IAAU,gBAAQ;AAJhC,2BAMI,YAAY,IAAU,kBAAU;AANpC,2BAOI,gBAAgB,IAAI,MAA0C;AAPlE,2BAQI,YAAY,IAAU,gBAAQ;AARxC,IAAM,4BAAN;",
6
6
  "names": ["THREE", "THREE", "THREE", "THREE", "THREE", "LoadingInstanceManager", "THREE", "THREE", "THREE", "THREE", "THREE", "LoadingInstanceManager", "THREE", "THREE", "THREE", "THREE", "CanvasText", "THREE", "THREE", "THREE", "calculateContentSize", "THREE", "audioRefDistance", "audioRolloffFactor", "MElement", "TransformableElement", "THREE", "THREE"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mml-io/mml-web-threejs",
3
- "version": "0.19.2",
3
+ "version": "0.19.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -20,8 +20,8 @@
20
20
  "test-iterate": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@mml-io/mml-web": "^0.19.2",
24
- "@mml-io/model-loader": "^0.19.2"
23
+ "@mml-io/mml-web": "^0.19.4",
24
+ "@mml-io/model-loader": "^0.19.4"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "three": "*"
@@ -35,5 +35,5 @@
35
35
  "@babel/preset-typescript"
36
36
  ]
37
37
  },
38
- "gitHead": "e1926507273fca794f77211d76fbcef178318987"
38
+ "gitHead": "23450b2f32b4826a3748ed624dab9e6f94558861"
39
39
  }