@mml-io/3d-web-client-core 0.0.0-experimental-16d1b9c-20241218 → 0.0.0-experimental-8dada83-20250122

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.
@@ -1,4 +1,4 @@
1
- import { PositionAndRotation } from "mml-web";
1
+ import { PositionAndRotation } from "@mml-io/mml-web";
2
2
  import { Euler, Group, Vector3 } from "three";
3
3
  import { CameraManager } from "../camera/CameraManager";
4
4
  import { CollisionsManager } from "../collisions/CollisionsManager";
@@ -1,4 +1,4 @@
1
- import { MElement } from "mml-web";
1
+ import { MElement } from "@mml-io/mml-web";
2
2
  import { Group, Line3, Matrix4, Ray, Scene, Vector3 } from "three";
3
3
  import { MeshBVH } from "three-mesh-bvh";
4
4
  export type CollisionMeshState = {
@@ -0,0 +1,3 @@
1
+ import { PositionAndRotation } from "@mml-io/mml-web";
2
+ import { Object3D } from "three";
3
+ export declare function getRelativePositionAndRotationRelativeToObject(positionAndRotation: PositionAndRotation, container: Object3D): PositionAndRotation;
package/build/index.js CHANGED
@@ -2550,11 +2550,15 @@ var VirtualJoystick = class _VirtualJoystick {
2550
2550
  // src/mml/MMLCompositionScene.ts
2551
2551
  import {
2552
2552
  InteractionManager,
2553
- MMLClickTrigger,
2554
- PromptManager,
2555
2553
  LoadingProgressManager,
2556
- MMLDocumentTimeManager
2557
- } from "mml-web";
2554
+ MMLDocumentTimeManager,
2555
+ PromptManager
2556
+ } from "@mml-io/mml-web";
2557
+ import {
2558
+ ThreeJSClickTrigger,
2559
+ ThreeJSGraphicsInterface,
2560
+ ThreeJSInteractionAdapter
2561
+ } from "@mml-io/mml-web-threejs";
2558
2562
  import { Group as Group3 } from "three";
2559
2563
  var MMLCompositionScene = class {
2560
2564
  constructor(config) {
@@ -2562,21 +2566,55 @@ var MMLCompositionScene = class {
2562
2566
  this.chatProbes = /* @__PURE__ */ new Set();
2563
2567
  this.group = new Group3();
2564
2568
  this.promptManager = PromptManager.init(this.config.targetElement);
2569
+ const graphicsAdapter = {
2570
+ collisionType: null,
2571
+ containerType: null,
2572
+ getGraphicsAdapterFactory: () => {
2573
+ return ThreeJSGraphicsInterface;
2574
+ },
2575
+ getRootContainer: () => {
2576
+ return this.group;
2577
+ },
2578
+ interactionShouldShowDistance(interaction) {
2579
+ return ThreeJSInteractionAdapter.interactionShouldShowDistance(
2580
+ interaction,
2581
+ this.config.camera,
2582
+ this.config.scene
2583
+ );
2584
+ },
2585
+ dispose() {
2586
+ },
2587
+ getAudioListener: () => {
2588
+ return config.audioListener;
2589
+ },
2590
+ getCamera: () => {
2591
+ return config.camera;
2592
+ },
2593
+ getThreeScene: () => {
2594
+ return config.scene;
2595
+ },
2596
+ getUserPositionAndRotation: () => {
2597
+ return this.config.getUserPositionAndRotation();
2598
+ }
2599
+ };
2565
2600
  const { interactionListener, interactionManager } = InteractionManager.init(
2566
2601
  this.config.targetElement,
2567
- this.config.camera,
2568
- this.config.scene
2602
+ (interaction) => {
2603
+ return graphicsAdapter.interactionShouldShowDistance(interaction);
2604
+ }
2569
2605
  );
2570
2606
  this.interactionManager = interactionManager;
2571
2607
  this.interactionListener = interactionListener;
2572
2608
  this.loadingProgressManager = new LoadingProgressManager();
2573
2609
  this.documentTimeManager = new MMLDocumentTimeManager();
2574
2610
  this.mmlScene = {
2575
- getAudioListener: () => this.config.audioListener,
2576
- getRenderer: () => this.config.renderer,
2577
- getThreeScene: () => this.config.scene,
2611
+ getGraphicsAdapter() {
2612
+ return graphicsAdapter;
2613
+ },
2614
+ hasGraphicsAdapter() {
2615
+ return true;
2616
+ },
2578
2617
  getRootContainer: () => this.group,
2579
- getCamera: () => this.config.camera,
2580
2618
  addCollider: (object, mElement) => {
2581
2619
  this.config.collisionsManager.addMeshesGroup(object, mElement);
2582
2620
  },
@@ -2614,7 +2652,11 @@ var MMLCompositionScene = class {
2614
2652
  return this.loadingProgressManager;
2615
2653
  }
2616
2654
  };
2617
- this.clickTrigger = MMLClickTrigger.init(this.config.targetElement, this.mmlScene);
2655
+ this.clickTrigger = ThreeJSClickTrigger.init(
2656
+ this.config.targetElement,
2657
+ this.group,
2658
+ this.config.camera
2659
+ );
2618
2660
  }
2619
2661
  onChatMessage(message) {
2620
2662
  for (const chatProbe of this.chatProbes) {
@@ -5700,39 +5742,73 @@ var TimeManager = class {
5700
5742
  };
5701
5743
 
5702
5744
  // src/collisions/CollisionsManager.ts
5703
- import {
5704
- getRelativePositionAndRotationRelativeToObject,
5705
- MMLCollisionTrigger
5706
- } from "mml-web";
5745
+ import { MMLCollisionTrigger } from "@mml-io/mml-web";
5707
5746
  import {
5708
5747
  Box3,
5709
5748
  Color as Color8,
5710
5749
  DoubleSide,
5711
- Euler as Euler4,
5750
+ Euler as Euler5,
5712
5751
  Group as Group5,
5713
5752
  Line3 as Line32,
5714
- Matrix4 as Matrix46,
5753
+ Matrix4 as Matrix47,
5715
5754
  Mesh as Mesh5,
5716
5755
  MeshBasicMaterial as MeshBasicMaterial3,
5717
- Quaternion as Quaternion6,
5756
+ Quaternion as Quaternion7,
5718
5757
  Ray as Ray2,
5719
- Vector3 as Vector314
5758
+ Vector3 as Vector315
5720
5759
  } from "three";
5721
5760
  import { VertexNormalsHelper } from "three/examples/jsm/helpers/VertexNormalsHelper.js";
5722
5761
  import * as BufferGeometryUtils from "three/examples/jsm/utils/BufferGeometryUtils.js";
5723
5762
  import { MeshBVH, MeshBVHHelper } from "three-mesh-bvh";
5763
+
5764
+ // src/collisions/getRelativePositionAndRotationRelativeToObject.ts
5765
+ import { Euler as Euler4, Matrix4 as Matrix46, Quaternion as Quaternion6, Vector3 as Vector314 } from "three";
5766
+ var tempContainerMatrix = new Matrix46();
5767
+ var tempTargetMatrix = new Matrix46();
5768
+ var tempPositionVector = new Vector314();
5769
+ var tempRotationEuler = new Euler4();
5770
+ var tempRotationQuaternion = new Quaternion6();
5771
+ var tempScaleVector = new Vector314();
5772
+ function getRelativePositionAndRotationRelativeToObject(positionAndRotation, container) {
5773
+ const { x, y, z } = positionAndRotation.position;
5774
+ const { x: rx, y: ry, z: rz } = positionAndRotation.rotation;
5775
+ container.updateWorldMatrix(true, false);
5776
+ tempContainerMatrix.copy(container.matrixWorld).invert();
5777
+ tempPositionVector.set(x, y, z);
5778
+ tempRotationEuler.set(rx, ry, rz);
5779
+ tempRotationQuaternion.setFromEuler(tempRotationEuler);
5780
+ tempScaleVector.set(1, 1, 1);
5781
+ tempTargetMatrix.compose(tempPositionVector, tempRotationQuaternion, tempScaleVector);
5782
+ tempTargetMatrix.premultiply(tempContainerMatrix);
5783
+ tempTargetMatrix.decompose(tempPositionVector, tempRotationQuaternion, tempScaleVector);
5784
+ tempRotationEuler.setFromQuaternion(tempRotationQuaternion);
5785
+ return {
5786
+ position: {
5787
+ x: tempPositionVector.x,
5788
+ y: tempPositionVector.y,
5789
+ z: tempPositionVector.z
5790
+ },
5791
+ rotation: {
5792
+ x: tempRotationEuler.x,
5793
+ y: tempRotationEuler.y,
5794
+ z: tempRotationEuler.z
5795
+ }
5796
+ };
5797
+ }
5798
+
5799
+ // src/collisions/CollisionsManager.ts
5724
5800
  var CollisionsManager = class {
5725
5801
  constructor(scene) {
5726
5802
  this.debug = false;
5727
- this.tempVector = new Vector314();
5728
- this.tempVector2 = new Vector314();
5729
- this.tempVector3 = new Vector314();
5730
- this.tempQuaternion = new Quaternion6();
5803
+ this.tempVector = new Vector315();
5804
+ this.tempVector2 = new Vector315();
5805
+ this.tempVector3 = new Vector315();
5806
+ this.tempQuaternion = new Quaternion7();
5731
5807
  this.tempRay = new Ray2();
5732
- this.tempMatrix = new Matrix46();
5733
- this.tempMatrix2 = new Matrix46();
5808
+ this.tempMatrix = new Matrix47();
5809
+ this.tempMatrix2 = new Matrix47();
5734
5810
  this.tempBox = new Box3();
5735
- this.tempEuler = new Euler4();
5811
+ this.tempEuler = new Euler5();
5736
5812
  this.tempSegment = new Line32();
5737
5813
  this.tempSegment2 = new Line32();
5738
5814
  this.collisionMeshState = /* @__PURE__ */ new Map();
@@ -5742,7 +5818,7 @@ var CollisionsManager = class {
5742
5818
  raycastFirst(ray) {
5743
5819
  let minimumDistance = null;
5744
5820
  let minimumHit = null;
5745
- let minimumNormal = new Vector314();
5821
+ let minimumNormal = new Vector315();
5746
5822
  for (const [, collisionMeshState] of this.collisionMeshState) {
5747
5823
  this.tempRay.copy(ray).applyMatrix4(this.tempMatrix.copy(collisionMeshState.matrix).invert());
5748
5824
  const hit = collisionMeshState.meshBVH.raycastFirst(this.tempRay, DoubleSide);
@@ -5883,7 +5959,7 @@ var CollisionsManager = class {
5883
5959
  const realDistance = intersectionSegment.distance();
5884
5960
  if (realDistance < capsuleRadius) {
5885
5961
  if (!collisionPosition) {
5886
- collisionPosition = new Vector314().copy(closestPointOnSegment).applyMatrix4(meshState.matrix);
5962
+ collisionPosition = new Vector315().copy(closestPointOnSegment).applyMatrix4(meshState.matrix);
5887
5963
  }
5888
5964
  const ratio = realDistance / modelReferenceDistance;
5889
5965
  const realDepth = capsuleRadius - realDistance;
@@ -5985,7 +6061,7 @@ var GroundPlane = class extends Group6 {
5985
6061
  };
5986
6062
 
5987
6063
  // src/loading-screen/LoadingScreen.ts
5988
- import { LoadingProgressManager as LoadingProgressManager2 } from "mml-web";
6064
+ import { LoadingProgressManager as LoadingProgressManager2 } from "@mml-io/mml-web";
5989
6065
  var LoadingScreen = class {
5990
6066
  constructor(loadingProgressManager, config) {
5991
6067
  this.loadingProgressManager = loadingProgressManager;