@luminocity/lemonate-engine 26.3.9 → 26.3.12

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.
@@ -41307,7 +41307,7 @@
41307
41307
  }
41308
41308
  }
41309
41309
 
41310
- var engine$1 = "26.3.9";
41310
+ var engine$1 = "26.3.12";
41311
41311
  var bullet = "3.26";
41312
41312
  var lua = "5.4.3";
41313
41313
  var packageVersionInfo = {
@@ -67234,9 +67234,9 @@
67234
67234
  this.state = exports.ItemState.Created;
67235
67235
  this._loadingManagerProgress(LoadingState.LOADING);
67236
67236
  this.splats = new THREE.Object3D();
67237
- this.preloadAndReturnUrl().then((url) => {
67237
+ this.preloadAndReturnUrl(undefined, { returnObjectUrlAlso: true }).then((urls) => {
67238
67238
  const profilerTask = this.engine.profiler.start('GaussianSplats', `Loading ${this.item.name}`);
67239
- new SplatMesh({ url: url, onLoad: async (splatMesh) => {
67239
+ new SplatMesh({ url: urls.objectUrl, onLoad: async (splatMesh) => {
67240
67240
  this.splatMesh = splatMesh;
67241
67241
  this._loadingManagerProgress(LoadingState.DONE);
67242
67242
  this.splats.add(this.splatMesh);
@@ -104467,6 +104467,11 @@
104467
104467
  class SgItem extends SgResourceOwner {
104468
104468
  //The block stores the underlying model of the SgItem. It must be set. If it is not passed, an empty one will be created.
104469
104469
  block;
104470
+ // active means the object exists in 3d world, scripts are running, physics is active
104471
+ active = true;
104472
+ // This means the object is actually rendered. It is an additional flag on top of active,
104473
+ // if it's not active, it is also not rendered but not vice versa
104474
+ rendered = true;
104470
104475
  state;
104471
104476
  fieldMap; // quick lookup of fields by name
104472
104477
  parent;
@@ -104479,7 +104484,6 @@
104479
104484
  selected = false;
104480
104485
  children = [];
104481
104486
  itemId;
104482
- visible = true;
104483
104487
  autoRecreate = true;
104484
104488
  recreationMutex = new Mutex();
104485
104489
  container = new THREE.Group();
@@ -104691,8 +104695,17 @@
104691
104695
  }
104692
104696
  resume() {
104693
104697
  }
104694
- setActive(active) {
104695
- if (!active) {
104698
+ isRendered() {
104699
+ return this.active && this.rendered;
104700
+ }
104701
+ isActive() {
104702
+ return this.active;
104703
+ }
104704
+ async updateActive() {
104705
+ const newActive = this.getFieldValue("Active");
104706
+ if (newActive === this.active)
104707
+ return;
104708
+ if (!newActive && this.active) {
104696
104709
  try {
104697
104710
  this.deactivate();
104698
104711
  }
@@ -104700,8 +104713,7 @@
104700
104713
  console.error("Error when deactivating: ", err);
104701
104714
  }
104702
104715
  }
104703
- this.show(active);
104704
- if (active) {
104716
+ if (newActive && !this.active) {
104705
104717
  try {
104706
104718
  this.activate();
104707
104719
  }
@@ -104709,6 +104721,16 @@
104709
104721
  console.error("Error when deactivating: ", err);
104710
104722
  }
104711
104723
  }
104724
+ this.active = newActive;
104725
+ this.updatePhysicsFromFields(true);
104726
+ this.updateParticleSystemPreview(true);
104727
+ return this._setScriptsEnabled(this.active);
104728
+ }
104729
+ updateRendered() {
104730
+ this.rendered = this.getFieldValue("Rendered");
104731
+ const obj = this.getContainer();
104732
+ if (obj)
104733
+ obj.visible = this.isRendered();
104712
104734
  }
104713
104735
  activate() {
104714
104736
  for (const child of this.children) {
@@ -104720,15 +104742,15 @@
104720
104742
  child.deactivate();
104721
104743
  }
104722
104744
  }
104723
- isEnabled() {
104724
- return this.getFieldValue("Active");
104745
+ setActive(active) {
104746
+ this.setFieldValue("Active", active);
104725
104747
  }
104726
104748
  enable() {
104727
- if (!this.isEnabled())
104749
+ if (!this.isActive())
104728
104750
  this.setFieldValue("Active", true);
104729
104751
  }
104730
104752
  disable() {
104731
- if (this.isEnabled())
104753
+ if (this.isActive())
104732
104754
  this.setFieldValue("Active", false);
104733
104755
  }
104734
104756
  getItemId() {
@@ -105197,7 +105219,12 @@
105197
105219
  updateEvent(field, value, type, oldValue) {
105198
105220
  switch (field) {
105199
105221
  case "Active": {
105200
- this.setActive(value);
105222
+ this.updateActive();
105223
+ this.updateRendered();
105224
+ break;
105225
+ }
105226
+ case "Rendered": {
105227
+ this.updateRendered();
105201
105228
  break;
105202
105229
  }
105203
105230
  case "Layers": {
@@ -105253,7 +105280,7 @@
105253
105280
  this.setPhysicsFromFields(allAncestorsAreActive, recursively);
105254
105281
  }
105255
105282
  setPhysicsFromFields(allAncestorsActive, recursively) {
105256
- const isActive = this.isEnabled();
105283
+ const isActive = this.isActive();
105257
105284
  if (this.isPhysicsItem()) {
105258
105285
  const pi = this;
105259
105286
  const isPhysicsEnabled = pi.isPhysicsEnabled();
@@ -105272,7 +105299,7 @@
105272
105299
  // Helper function to toggle the particle system preview based on parent active status.
105273
105300
  updateParticleSystemPreview(recursively) {
105274
105301
  const allAncestorsActive = this.allAncestorsAreActive();
105275
- const isActive = this.isEnabled();
105302
+ const isActive = this.isActive();
105276
105303
  if (this.isParticlesItem()) {
105277
105304
  const particles = this;
105278
105305
  if (particles.system) {
@@ -105675,11 +105702,12 @@
105675
105702
  if (restartPlayback)
105676
105703
  this.stop();
105677
105704
  this.destroy(false, false, true);
105678
- this.visible = this.getFieldValue("Active");
105705
+ this.updateActive();
105706
+ this.updateRendered();
105679
105707
  await creationFunc();
105680
105708
  const obj = this.getObject();
105681
105709
  this.addChildrenObjects();
105682
- this.container.visible = this.visible;
105710
+ this.container.visible = this.isRendered();
105683
105711
  if (obj) {
105684
105712
  this.container.add(obj);
105685
105713
  }
@@ -105764,22 +105792,11 @@
105764
105792
  if (this.parent)
105765
105793
  this.parent.remove(this);
105766
105794
  }
105767
- show(value) {
105768
- if (this.visible === value)
105769
- return;
105770
- this.visible = value;
105771
- const obj = this.getContainer();
105772
- if (obj)
105773
- obj.visible = value;
105774
- this.updatePhysicsFromFields(true);
105775
- this.updateParticleSystemPreview(true);
105776
- return this._setScriptsEnabled(value);
105777
- }
105778
105795
  allAncestorsAreActive() {
105779
105796
  let currNode = this.parent;
105780
105797
  while (currNode) {
105781
105798
  const parent = currNode.getParent();
105782
- const isActive = currNode.isEnabled();
105799
+ const isActive = currNode.isActive();
105783
105800
  if (!isActive) {
105784
105801
  return false;
105785
105802
  }
@@ -106314,6 +106331,47 @@
106314
106331
  }
106315
106332
  }
106316
106333
 
106334
+ // -----------------------------------------------------------------------------------------------------------
106335
+ // __ ______ __ __ ______ __ __ ______ ______ ______
106336
+ // /\ \ /\ ___\ /\ "-./ \ /\ __ \ /\ "-.\ \ /\ __ \ /\__ _\ /\ ___\
106337
+ // \ \ \____ \ \ __\ \ \ \-./\ \ \ \ \/\ \ \ \ \-. \ \ \ __ \ \/_/\ \/ \ \ __\
106338
+ // \ \_____\ \ \_____\ \ \_\ \ \_\ \ \_____\ \ \_\\"\_\ \ \_\ \_\ \ \_\ \ \_____\
106339
+ // \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_/ \/_/ \/_/\/_/ \/_/ \/_____/
106340
+ //
106341
+ //
106342
+ // Copyright 2023- Luminocity AG
106343
+ //
106344
+ // "Do a barrel roll!" - Star Fox 64 (1997)
106345
+ //
106346
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software
106347
+ // and associated documentation files (the “Software”), to deal in the Software without restriction,
106348
+ // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
106349
+ // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
106350
+ // subject to the following conditions:
106351
+ //
106352
+ // The above copyright notice and this permission notice shall be included in all copies or substantial
106353
+ // portions of the Software.
106354
+ //
106355
+ // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
106356
+ // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
106357
+ // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
106358
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
106359
+ // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
106360
+ // -----------------------------------------------------------------------------------------------------------
106361
+ class ColliderHelper extends THREE.Mesh {
106362
+ type = 'ColliderHelper';
106363
+ isHelper = true;
106364
+ item;
106365
+ constructor(item) {
106366
+ super();
106367
+ this.item = item;
106368
+ }
106369
+ update() {
106370
+ const data = this.item.getPhysicsData();
106371
+ console.log("Physics data: ", data);
106372
+ }
106373
+ }
106374
+
106317
106375
  // -----------------------------------------------------------------------------------------------------------
106318
106376
  // __ ______ __ __ ______ __ __ ______ ______ ______
106319
106377
  // /\ \ /\ ___\ /\ "-./ \ /\ __ \ /\ "-.\ \ /\ __ \ /\__ _\ /\ ___\
@@ -106347,6 +106405,7 @@
106347
106405
  customMeshColliderMeshItem;
106348
106406
  customMeshCollider;
106349
106407
  customMeshColliderMeshCollection;
106408
+ colliderHelper;
106350
106409
  bodyType;
106351
106410
  _isAddingToPhysics = false;
106352
106411
  _onMeshCollectionUpdate;
@@ -106354,10 +106413,14 @@
106354
106413
  super(block, parent, scene, engine, position, sceneGraph);
106355
106414
  this.physics = this.engine.physics;
106356
106415
  this.physicsSubItems = [];
106416
+ this.colliderHelper = new ColliderHelper(this);
106357
106417
  this._resetPhysics();
106358
106418
  this._onMeshCollectionUpdate = (meshCollection) => {
106359
106419
  };
106360
106420
  }
106421
+ getColliderHelper() {
106422
+ return this.colliderHelper;
106423
+ }
106361
106424
  getSubItem(index) {
106362
106425
  if (this.physicsSubItems.length > index)
106363
106426
  return this.physicsSubItems[index];
@@ -106597,14 +106660,20 @@
106597
106660
  return objects;
106598
106661
  }
106599
106662
  getPhysicsData(separateSubobjects, callback) {
106600
- const dataArray = this._getPhysicsData(separateSubobjects);
106601
- if (dataArray.length) {
106602
- callback(dataArray);
106663
+ if (separateSubobjects === undefined) {
106664
+ separateSubobjects = this.getFieldValue("SeparateSubobjects");
106603
106665
  }
106604
- else {
106605
- this.$on("sgitem:recreated", () => this.invokeCallback(separateSubobjects, callback));
106606
- this.$on("sgphysicsitem:colliderupdated", () => this.invokeCallback(separateSubobjects, callback));
106666
+ const dataArray = this._getPhysicsData(separateSubobjects);
106667
+ if (callback) {
106668
+ if (dataArray.length) {
106669
+ callback(dataArray);
106670
+ }
106671
+ else {
106672
+ this.$on("sgitem:recreated", () => this.invokeCallback(separateSubobjects, callback));
106673
+ this.$on("sgphysicsitem:colliderupdated", () => this.invokeCallback(separateSubobjects, callback));
106674
+ }
106607
106675
  }
106676
+ return dataArray;
106608
106677
  }
106609
106678
  invokeCallback(separateSubobjects, callback) {
106610
106679
  const dataArray = this._getPhysicsData(separateSubobjects);
@@ -109053,7 +109122,7 @@
109053
109122
  return true;
109054
109123
  switch (field) {
109055
109124
  case "Active": {
109056
- this.show(value);
109125
+ this.updateActive();
109057
109126
  this._updateLightHelper();
109058
109127
  break;
109059
109128
  }
@@ -109684,7 +109753,7 @@
109684
109753
  create() {
109685
109754
  return undefined;
109686
109755
  }
109687
- isEnabled() {
109756
+ isActive() {
109688
109757
  const defaultReturnValue = true;
109689
109758
  try {
109690
109759
  const activeItemIsProject = this.itemRepo.activeItem?.type === "Project";
@@ -109703,8 +109772,8 @@
109703
109772
  }
109704
109773
  if (!foundBlock)
109705
109774
  return defaultReturnValue;
109706
- let isLoaded = null;
109707
- let isActive = null;
109775
+ let isLoaded = false;
109776
+ let isActive = false;
109708
109777
  for (const field of foundBlock.fields) {
109709
109778
  if (field.name === "Load") {
109710
109779
  isLoaded = field.value;
@@ -118264,7 +118333,7 @@
118264
118333
  }
118265
118334
  play() {
118266
118335
  super.play();
118267
- if (!this.system || !this.isEnabled() || this.system.isPaused)
118336
+ if (!this.system || !this.isActive() || this.system.isPaused)
118268
118337
  return;
118269
118338
  this._previewWasRunningBeforePlay = this.isRunningPreview;
118270
118339
  this.isRunning = true;
@@ -118617,13 +118686,14 @@
118617
118686
  this.particleHelper = null;
118618
118687
  }
118619
118688
  }
118620
- show(value) {
118621
- const toReturn = super.show(value);
118622
- const shouldPreview = this.allAncestorsAreActive() && this.isEnabled();
118689
+ async updateActive() {
118690
+ const promise = super.updateActive();
118691
+ const isActive = this.isActive();
118692
+ const shouldPreview = this.allAncestorsAreActive() && isActive;
118623
118693
  this.runPreview(shouldPreview);
118624
118694
  const shouldShowHelper = this.getFieldValue("ShowHelper");
118625
- this.showHelper(value && shouldShowHelper);
118626
- return toReturn;
118695
+ this.showHelper(isActive && shouldShowHelper);
118696
+ return promise;
118627
118697
  }
118628
118698
  updateEvent(field, value, type, oldValue) {
118629
118699
  const baseHandled = super.updateEvent(field, value, type, oldValue);
@@ -119228,7 +119298,7 @@
119228
119298
  }
119229
119299
  }
119230
119300
  playOrActivate() {
119231
- if (this.audio && this.isEnabled() && this._isPlaying) {
119301
+ if (this.audio && this.isActive() && this._isPlaying) {
119232
119302
  const autoplay = this.getFieldValue("Autoplay", false);
119233
119303
  // If the audio is not yet loaded, starting the playback now will
119234
119304
  // prevent the audio from playing after it has been loaded because
@@ -128273,7 +128343,7 @@
128273
128343
  if (needsToBeInitialized && !script.initialized)
128274
128344
  continue;
128275
128345
  const sgNode = script.parentItem;
128276
- if (sgNode.isEnabled() && sgNode.allAncestorsAreActive())
128346
+ if (sgNode.isActive() && sgNode.allAncestorsAreActive())
128277
128347
  func(script);
128278
128348
  }
128279
128349
  catch (err) {
@@ -133669,7 +133739,7 @@
133669
133739
  if (!obj)
133670
133740
  return false;
133671
133741
  if (obj instanceof SgItem) {
133672
- return obj.isEnabled();
133742
+ return obj.isActive();
133673
133743
  }
133674
133744
  return false;
133675
133745
  }
@@ -134370,7 +134440,7 @@
134370
134440
  }
134371
134441
  play(params) {
134372
134442
  const sgaudio = this._getParamSceneObject(params.obj, SgAudio, false);
134373
- if (sgaudio && sgaudio.isEnabled()) {
134443
+ if (sgaudio && sgaudio.isActive()) {
134374
134444
  const audio = sgaudio.getObject();
134375
134445
  if (audio) {
134376
134446
  if (audio.isPlaying && params.force)
@@ -148848,6 +148918,20 @@
148848
148918
  defaultAction: "Use",
148849
148919
  actions: ["Skip", "Use"]
148850
148920
  },
148921
+ "sog": {
148922
+ name: "SOG",
148923
+ itemType: "Gaussian Splats",
148924
+ folderName: "gaussiansplats",
148925
+ defaultAction: "Use",
148926
+ actions: ["Skip", "Use"]
148927
+ },
148928
+ "spz": {
148929
+ name: "SPZ",
148930
+ itemType: "Gaussian Splats",
148931
+ folderName: "gaussiansplats",
148932
+ defaultAction: "Use",
148933
+ actions: ["Skip", "Use"]
148934
+ },
148851
148935
  "material": {
148852
148936
  name: "JSON",
148853
148937
  itemType: "Material",
package/dist/player.zip CHANGED
Binary file
@@ -22,6 +22,8 @@ export declare enum SgItemState {
22
22
  }
23
23
  export declare abstract class SgItem extends SgResourceOwner {
24
24
  readonly block: Block;
25
+ active: boolean;
26
+ rendered: boolean;
25
27
  state: SgItemState;
26
28
  fieldMap: Map<string, Field>;
27
29
  parent?: SgItem;
@@ -34,7 +36,6 @@ export declare abstract class SgItem extends SgResourceOwner {
34
36
  selected: boolean;
35
37
  children: SgItem[];
36
38
  itemId?: string;
37
- visible: boolean;
38
39
  autoRecreate: boolean;
39
40
  recreationMutex: Mutex;
40
41
  container: Object3D;
@@ -74,10 +75,13 @@ export declare abstract class SgItem extends SgResourceOwner {
74
75
  stop(): void;
75
76
  pause(): void;
76
77
  resume(): void;
77
- setActive(active: boolean): void;
78
+ isRendered(): boolean;
79
+ isActive(): boolean;
80
+ updateActive(): Promise<void[] | undefined>;
81
+ updateRendered(): void;
78
82
  activate(): void;
79
83
  deactivate(): void;
80
- isEnabled(): any;
84
+ setActive(active: boolean): void;
81
85
  enable(): void;
82
86
  disable(): void;
83
87
  getItemId(): string | null;
@@ -104,7 +108,7 @@ export declare abstract class SgItem extends SgResourceOwner {
104
108
  setContentHookEnabled(value: boolean): void;
105
109
  configure(cfg: any): void;
106
110
  _initScripts(): Promise<void>;
107
- _setScriptsEnabled(value: boolean): Promise<any[]>;
111
+ _setScriptsEnabled(value: boolean): Promise<void[]>;
108
112
  _destroyScripts(): void;
109
113
  addScript(scriptMeta: ScriptMeta): Promise<void>;
110
114
  removeScript(scriptMeta: ScriptMeta): void;
@@ -301,7 +305,6 @@ export declare abstract class SgItem extends SgResourceOwner {
301
305
  destroyChildren(): void;
302
306
  destroy(noDispose?: boolean, withChildren?: boolean, noRemoveUpdateListener?: boolean): void;
303
307
  destroyAndRemove(): void;
304
- show(value: boolean): Promise<any[]> | undefined;
305
308
  allAncestorsAreActive(): boolean;
306
309
  getLayerIndices(): any;
307
310
  takeSnapshot(recursive: boolean): {
@@ -31,6 +31,6 @@ export declare class SgParticles extends SgItem {
31
31
  private _createParticleHelper;
32
32
  private _createArrow;
33
33
  private _cleanupParticleHelper;
34
- show(value: boolean): any;
34
+ updateActive(): Promise<void[] | undefined>;
35
35
  updateEvent(field: string, value: any, type: string, oldValue: any): boolean;
36
36
  }
@@ -8,6 +8,7 @@ import { Engine } from "@/Engine";
8
8
  import { SceneGraph } from "@/SceneGraph";
9
9
  import { MeshItem as MeshItem } from '../items/MeshItem';
10
10
  import { MeshCollectionItem } from '@/items/MeshCollectionItem';
11
+ import { ColliderHelper } from "@/helpers/ColliderHelper";
11
12
  export type SgPhysicsItemTraversalFunc = (item: SgPhysicsSubItem) => void;
12
13
  export declare abstract class SgPhysicsItem extends SgItem {
13
14
  physics: Physics;
@@ -15,10 +16,12 @@ export declare abstract class SgPhysicsItem extends SgItem {
15
16
  customMeshColliderMeshItem?: MeshItem;
16
17
  customMeshCollider: any;
17
18
  customMeshColliderMeshCollection?: MeshCollectionItem;
19
+ colliderHelper: ColliderHelper;
18
20
  bodyType?: string;
19
21
  private _isAddingToPhysics;
20
22
  private readonly _onMeshCollectionUpdate;
21
23
  constructor(block: Block, parent: SgItem, scene: ExtendedScene, engine: Engine, position: number, sceneGraph: SceneGraph);
24
+ getColliderHelper(): ColliderHelper;
22
25
  getSubItem(index: number): SgPhysicsSubItem | null;
23
26
  _resetPhysics(): void;
24
27
  forEachSubItem(func: SgPhysicsItemTraversalFunc): void;
@@ -54,7 +57,7 @@ export declare abstract class SgPhysicsItem extends SgItem {
54
57
  _setColliderMeshItem(item: any): void;
55
58
  _freeCollider(): void;
56
59
  _getPhysicsData(separateSubobjects?: boolean): any[];
57
- getPhysicsData(separateSubobjects: boolean, callback: Function): void;
60
+ getPhysicsData(separateSubobjects?: boolean, callback?: Function): any[];
58
61
  invokeCallback(separateSubobjects: boolean, callback: Function): void;
59
62
  getSelfCollider(): any;
60
63
  _getBoundingCylinder(mesh: Object3D): {
@@ -2,7 +2,7 @@ import { SgItem } from './SgItem.js';
2
2
  export declare class SgRoot extends SgItem {
3
3
  getType(): string;
4
4
  create(): undefined;
5
- isEnabled(): true | null;
5
+ isActive(): boolean;
6
6
  /**
7
7
  * Creates a list of all item children of this scene graph
8
8
  * @returns {*[]}
@@ -66,7 +66,7 @@ export declare class RtSceneObject extends RtBase {
66
66
  delete(params: RuntimeParams): void;
67
67
  takeSnapshot(params: RuntimeParams): number | null;
68
68
  rollbackSnapshot(params: RuntimeParams): null | undefined;
69
- isEnabled(params: RuntimeParams): any;
69
+ isEnabled(params: RuntimeParams): boolean;
70
70
  enable(params: RuntimeParams): null | undefined;
71
71
  disable(params: RuntimeParams): null | undefined;
72
72
  getParent(params: RuntimeParams): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luminocity/lemonate-engine",
3
- "version": "26.3.9",
3
+ "version": "26.3.12",
4
4
  "productName": "Lemonate Engine",
5
5
  "repository": "https://codeberg.org/Luminocity/lemonate-engine",
6
6
  "homepage": "https://lemonate.io",
@@ -43,7 +43,7 @@
43
43
  "dependencies": {
44
44
  "@gltf-transform/core": "^4.0.1",
45
45
  "@gltf-transform/extensions": "^4.0.1",
46
- "@luminocity/lemonate-gateway": "8.2.19",
46
+ "@luminocity/lemonate-gateway": "8.2.22",
47
47
  "@msgpack/msgpack": "3.1.1",
48
48
  "@recast-navigation/three": "^0.42.0",
49
49
  "@sparkjsdev/spark": "^0.1.10",