@luminocity/lemonate-engine 26.3.10 → 26.3.13

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/dist/Player.d.ts CHANGED
@@ -39,7 +39,7 @@ export declare class Player {
39
39
  isLooping(): boolean;
40
40
  getGameTime(): any;
41
41
  getTime(): any;
42
- withMainCanvas(func: Function): Promise<any>;
42
+ withMainCanvas(func: Function): Promise<void>;
43
43
  pushEvent(event: any): boolean;
44
44
  waitForScriptAdded(metaScript: any): Promise<unknown>;
45
45
  getScriptEntryFromMetaScript(metaScript: any): import("./SceneGraphCollection").ScriptEntry | undefined;
@@ -57,6 +57,6 @@ export declare class Player {
57
57
  render(): Promise<any[]> | undefined;
58
58
  needToRenderGui(): boolean;
59
59
  renderGui(): Promise<any[] | undefined>;
60
- setScriptEnabled(itemScript: any, value: any): Promise<any>;
60
+ setScriptEnabled(itemScript: any, value: any): Promise<void>;
61
61
  stop(): Promise<void>;
62
62
  }
@@ -0,0 +1,9 @@
1
+ import { SgPhysicsItem } from "@/scenegraph/SgPhysicsItem";
2
+ import { Mesh } from "three";
3
+ export declare class ColliderHelper extends Mesh {
4
+ readonly type: string;
5
+ isHelper: boolean;
6
+ private item;
7
+ constructor(item: SgPhysicsItem);
8
+ update(): void;
9
+ }
@@ -41290,7 +41290,7 @@ class Item extends EventEmitter {
41290
41290
  }
41291
41291
  }
41292
41292
 
41293
- var engine$1 = "26.3.10";
41293
+ var engine$1 = "26.3.13";
41294
41294
  var bullet = "3.26";
41295
41295
  var lua = "5.4.3";
41296
41296
  var packageVersionInfo = {
@@ -67217,9 +67217,9 @@ class GaussianSplatsItem extends Item {
67217
67217
  this.state = ItemState.Created;
67218
67218
  this._loadingManagerProgress(LoadingState.LOADING);
67219
67219
  this.splats = new Object3D();
67220
- this.preloadAndReturnUrl().then((url) => {
67220
+ this.preloadAndReturnUrl(undefined, { returnObjectUrlAlso: true }).then((urls) => {
67221
67221
  const profilerTask = this.engine.profiler.start('GaussianSplats', `Loading ${this.item.name}`);
67222
- new SplatMesh({ url: url, onLoad: async (splatMesh) => {
67222
+ new SplatMesh({ url: urls.objectUrl, onLoad: async (splatMesh) => {
67223
67223
  this.splatMesh = splatMesh;
67224
67224
  this._loadingManagerProgress(LoadingState.DONE);
67225
67225
  this.splats.add(this.splatMesh);
@@ -104450,6 +104450,11 @@ var SgItemState;
104450
104450
  class SgItem extends SgResourceOwner {
104451
104451
  //The block stores the underlying model of the SgItem. It must be set. If it is not passed, an empty one will be created.
104452
104452
  block;
104453
+ // active means the object exists in 3d world, scripts are running, physics is active
104454
+ active = true;
104455
+ // This means the object is actually rendered. It is an additional flag on top of active,
104456
+ // if it's not active, it is also not rendered but not vice versa
104457
+ rendered = true;
104453
104458
  state;
104454
104459
  fieldMap; // quick lookup of fields by name
104455
104460
  parent;
@@ -104462,7 +104467,6 @@ class SgItem extends SgResourceOwner {
104462
104467
  selected = false;
104463
104468
  children = [];
104464
104469
  itemId;
104465
- visible = true;
104466
104470
  autoRecreate = true;
104467
104471
  recreationMutex = new Mutex();
104468
104472
  container = new Group();
@@ -104674,8 +104678,17 @@ class SgItem extends SgResourceOwner {
104674
104678
  }
104675
104679
  resume() {
104676
104680
  }
104677
- setActive(active) {
104678
- if (!active) {
104681
+ isRendered() {
104682
+ return this.active && this.rendered;
104683
+ }
104684
+ isActive() {
104685
+ return this.active;
104686
+ }
104687
+ async updateActive() {
104688
+ const newActive = this.getFieldValue("Active");
104689
+ if (newActive === this.active)
104690
+ return;
104691
+ if (!newActive && this.active) {
104679
104692
  try {
104680
104693
  this.deactivate();
104681
104694
  }
@@ -104683,8 +104696,7 @@ class SgItem extends SgResourceOwner {
104683
104696
  console.error("Error when deactivating: ", err);
104684
104697
  }
104685
104698
  }
104686
- this.show(active);
104687
- if (active) {
104699
+ if (newActive && !this.active) {
104688
104700
  try {
104689
104701
  this.activate();
104690
104702
  }
@@ -104692,6 +104704,16 @@ class SgItem extends SgResourceOwner {
104692
104704
  console.error("Error when deactivating: ", err);
104693
104705
  }
104694
104706
  }
104707
+ this.active = newActive;
104708
+ this.updatePhysicsFromFields(true);
104709
+ this.updateParticleSystemPreview(true);
104710
+ return this._setScriptsEnabled(this.active);
104711
+ }
104712
+ updateRendered() {
104713
+ this.rendered = this.getFieldValue("Rendered");
104714
+ const obj = this.getContainer();
104715
+ if (obj)
104716
+ obj.visible = this.isRendered();
104695
104717
  }
104696
104718
  activate() {
104697
104719
  for (const child of this.children) {
@@ -104703,15 +104725,15 @@ class SgItem extends SgResourceOwner {
104703
104725
  child.deactivate();
104704
104726
  }
104705
104727
  }
104706
- isEnabled() {
104707
- return this.getFieldValue("Active");
104728
+ setActive(active) {
104729
+ this.setFieldValue("Active", active);
104708
104730
  }
104709
104731
  enable() {
104710
- if (!this.isEnabled())
104732
+ if (!this.isActive())
104711
104733
  this.setFieldValue("Active", true);
104712
104734
  }
104713
104735
  disable() {
104714
- if (this.isEnabled())
104736
+ if (this.isActive())
104715
104737
  this.setFieldValue("Active", false);
104716
104738
  }
104717
104739
  getItemId() {
@@ -105180,7 +105202,12 @@ class SgItem extends SgResourceOwner {
105180
105202
  updateEvent(field, value, type, oldValue) {
105181
105203
  switch (field) {
105182
105204
  case "Active": {
105183
- this.setActive(value);
105205
+ this.updateActive();
105206
+ this.updateRendered();
105207
+ break;
105208
+ }
105209
+ case "Rendered": {
105210
+ this.updateRendered();
105184
105211
  break;
105185
105212
  }
105186
105213
  case "Layers": {
@@ -105236,7 +105263,7 @@ class SgItem extends SgResourceOwner {
105236
105263
  this.setPhysicsFromFields(allAncestorsAreActive, recursively);
105237
105264
  }
105238
105265
  setPhysicsFromFields(allAncestorsActive, recursively) {
105239
- const isActive = this.isEnabled();
105266
+ const isActive = this.isActive();
105240
105267
  if (this.isPhysicsItem()) {
105241
105268
  const pi = this;
105242
105269
  const isPhysicsEnabled = pi.isPhysicsEnabled();
@@ -105255,7 +105282,7 @@ class SgItem extends SgResourceOwner {
105255
105282
  // Helper function to toggle the particle system preview based on parent active status.
105256
105283
  updateParticleSystemPreview(recursively) {
105257
105284
  const allAncestorsActive = this.allAncestorsAreActive();
105258
- const isActive = this.isEnabled();
105285
+ const isActive = this.isActive();
105259
105286
  if (this.isParticlesItem()) {
105260
105287
  const particles = this;
105261
105288
  if (particles.system) {
@@ -105658,11 +105685,12 @@ class SgItem extends SgResourceOwner {
105658
105685
  if (restartPlayback)
105659
105686
  this.stop();
105660
105687
  this.destroy(false, false, true);
105661
- this.visible = this.getFieldValue("Active");
105688
+ this.updateActive();
105689
+ this.updateRendered();
105662
105690
  await creationFunc();
105663
105691
  const obj = this.getObject();
105664
105692
  this.addChildrenObjects();
105665
- this.container.visible = this.visible;
105693
+ this.container.visible = this.isRendered();
105666
105694
  if (obj) {
105667
105695
  this.container.add(obj);
105668
105696
  }
@@ -105747,22 +105775,11 @@ class SgItem extends SgResourceOwner {
105747
105775
  if (this.parent)
105748
105776
  this.parent.remove(this);
105749
105777
  }
105750
- show(value) {
105751
- if (this.visible === value)
105752
- return;
105753
- this.visible = value;
105754
- const obj = this.getContainer();
105755
- if (obj)
105756
- obj.visible = value;
105757
- this.updatePhysicsFromFields(true);
105758
- this.updateParticleSystemPreview(true);
105759
- return this._setScriptsEnabled(value);
105760
- }
105761
105778
  allAncestorsAreActive() {
105762
105779
  let currNode = this.parent;
105763
105780
  while (currNode) {
105764
105781
  const parent = currNode.getParent();
105765
- const isActive = currNode.isEnabled();
105782
+ const isActive = currNode.isActive();
105766
105783
  if (!isActive) {
105767
105784
  return false;
105768
105785
  }
@@ -106297,6 +106314,47 @@ class SgPhysicsSubItem {
106297
106314
  }
106298
106315
  }
106299
106316
 
106317
+ // -----------------------------------------------------------------------------------------------------------
106318
+ // __ ______ __ __ ______ __ __ ______ ______ ______
106319
+ // /\ \ /\ ___\ /\ "-./ \ /\ __ \ /\ "-.\ \ /\ __ \ /\__ _\ /\ ___\
106320
+ // \ \ \____ \ \ __\ \ \ \-./\ \ \ \ \/\ \ \ \ \-. \ \ \ __ \ \/_/\ \/ \ \ __\
106321
+ // \ \_____\ \ \_____\ \ \_\ \ \_\ \ \_____\ \ \_\\"\_\ \ \_\ \_\ \ \_\ \ \_____\
106322
+ // \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_/ \/_/ \/_/\/_/ \/_/ \/_____/
106323
+ //
106324
+ //
106325
+ // Copyright 2023- Luminocity AG
106326
+ //
106327
+ // "Do a barrel roll!" - Star Fox 64 (1997)
106328
+ //
106329
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software
106330
+ // and associated documentation files (the “Software”), to deal in the Software without restriction,
106331
+ // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
106332
+ // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
106333
+ // subject to the following conditions:
106334
+ //
106335
+ // The above copyright notice and this permission notice shall be included in all copies or substantial
106336
+ // portions of the Software.
106337
+ //
106338
+ // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
106339
+ // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
106340
+ // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
106341
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
106342
+ // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
106343
+ // -----------------------------------------------------------------------------------------------------------
106344
+ class ColliderHelper extends Mesh {
106345
+ type = 'ColliderHelper';
106346
+ isHelper = true;
106347
+ item;
106348
+ constructor(item) {
106349
+ super();
106350
+ this.item = item;
106351
+ }
106352
+ update() {
106353
+ const data = this.item.getPhysicsData();
106354
+ console.log("Physics data: ", data);
106355
+ }
106356
+ }
106357
+
106300
106358
  // -----------------------------------------------------------------------------------------------------------
106301
106359
  // __ ______ __ __ ______ __ __ ______ ______ ______
106302
106360
  // /\ \ /\ ___\ /\ "-./ \ /\ __ \ /\ "-.\ \ /\ __ \ /\__ _\ /\ ___\
@@ -106330,6 +106388,7 @@ class SgPhysicsItem extends SgItem {
106330
106388
  customMeshColliderMeshItem;
106331
106389
  customMeshCollider;
106332
106390
  customMeshColliderMeshCollection;
106391
+ colliderHelper;
106333
106392
  bodyType;
106334
106393
  _isAddingToPhysics = false;
106335
106394
  _onMeshCollectionUpdate;
@@ -106337,10 +106396,14 @@ class SgPhysicsItem extends SgItem {
106337
106396
  super(block, parent, scene, engine, position, sceneGraph);
106338
106397
  this.physics = this.engine.physics;
106339
106398
  this.physicsSubItems = [];
106399
+ this.colliderHelper = new ColliderHelper(this);
106340
106400
  this._resetPhysics();
106341
106401
  this._onMeshCollectionUpdate = (meshCollection) => {
106342
106402
  };
106343
106403
  }
106404
+ getColliderHelper() {
106405
+ return this.colliderHelper;
106406
+ }
106344
106407
  getSubItem(index) {
106345
106408
  if (this.physicsSubItems.length > index)
106346
106409
  return this.physicsSubItems[index];
@@ -106580,14 +106643,20 @@ class SgPhysicsItem extends SgItem {
106580
106643
  return objects;
106581
106644
  }
106582
106645
  getPhysicsData(separateSubobjects, callback) {
106583
- const dataArray = this._getPhysicsData(separateSubobjects);
106584
- if (dataArray.length) {
106585
- callback(dataArray);
106646
+ if (separateSubobjects === undefined) {
106647
+ separateSubobjects = this.getFieldValue("SeparateSubobjects");
106586
106648
  }
106587
- else {
106588
- this.$on("sgitem:recreated", () => this.invokeCallback(separateSubobjects, callback));
106589
- this.$on("sgphysicsitem:colliderupdated", () => this.invokeCallback(separateSubobjects, callback));
106649
+ const dataArray = this._getPhysicsData(separateSubobjects);
106650
+ if (callback) {
106651
+ if (dataArray.length) {
106652
+ callback(dataArray);
106653
+ }
106654
+ else {
106655
+ this.$on("sgitem:recreated", () => this.invokeCallback(separateSubobjects, callback));
106656
+ this.$on("sgphysicsitem:colliderupdated", () => this.invokeCallback(separateSubobjects, callback));
106657
+ }
106590
106658
  }
106659
+ return dataArray;
106591
106660
  }
106592
106661
  invokeCallback(separateSubobjects, callback) {
106593
106662
  const dataArray = this._getPhysicsData(separateSubobjects);
@@ -109036,7 +109105,7 @@ class SgLightsource extends SgItem {
109036
109105
  return true;
109037
109106
  switch (field) {
109038
109107
  case "Active": {
109039
- this.show(value);
109108
+ this.updateActive();
109040
109109
  this._updateLightHelper();
109041
109110
  break;
109042
109111
  }
@@ -109667,7 +109736,7 @@ class SgRoot extends SgItem {
109667
109736
  create() {
109668
109737
  return undefined;
109669
109738
  }
109670
- isEnabled() {
109739
+ isActive() {
109671
109740
  const defaultReturnValue = true;
109672
109741
  try {
109673
109742
  const activeItemIsProject = this.itemRepo.activeItem?.type === "Project";
@@ -109686,8 +109755,8 @@ class SgRoot extends SgItem {
109686
109755
  }
109687
109756
  if (!foundBlock)
109688
109757
  return defaultReturnValue;
109689
- let isLoaded = null;
109690
- let isActive = null;
109758
+ let isLoaded = false;
109759
+ let isActive = false;
109691
109760
  for (const field of foundBlock.fields) {
109692
109761
  if (field.name === "Load") {
109693
109762
  isLoaded = field.value;
@@ -118247,7 +118316,7 @@ class SgParticles extends SgItem {
118247
118316
  }
118248
118317
  play() {
118249
118318
  super.play();
118250
- if (!this.system || !this.isEnabled() || this.system.isPaused)
118319
+ if (!this.system || !this.isActive() || this.system.isPaused)
118251
118320
  return;
118252
118321
  this._previewWasRunningBeforePlay = this.isRunningPreview;
118253
118322
  this.isRunning = true;
@@ -118600,13 +118669,14 @@ class SgParticles extends SgItem {
118600
118669
  this.particleHelper = null;
118601
118670
  }
118602
118671
  }
118603
- show(value) {
118604
- const toReturn = super.show(value);
118605
- const shouldPreview = this.allAncestorsAreActive() && this.isEnabled();
118672
+ async updateActive() {
118673
+ const promise = super.updateActive();
118674
+ const isActive = this.isActive();
118675
+ const shouldPreview = this.allAncestorsAreActive() && isActive;
118606
118676
  this.runPreview(shouldPreview);
118607
118677
  const shouldShowHelper = this.getFieldValue("ShowHelper");
118608
- this.showHelper(value && shouldShowHelper);
118609
- return toReturn;
118678
+ this.showHelper(isActive && shouldShowHelper);
118679
+ return promise;
118610
118680
  }
118611
118681
  updateEvent(field, value, type, oldValue) {
118612
118682
  const baseHandled = super.updateEvent(field, value, type, oldValue);
@@ -119211,7 +119281,7 @@ class SgAudio extends SgItem {
119211
119281
  }
119212
119282
  }
119213
119283
  playOrActivate() {
119214
- if (this.audio && this.isEnabled() && this._isPlaying) {
119284
+ if (this.audio && this.isActive() && this._isPlaying) {
119215
119285
  const autoplay = this.getFieldValue("Autoplay", false);
119216
119286
  // If the audio is not yet loaded, starting the playback now will
119217
119287
  // prevent the audio from playing after it has been loaded because
@@ -128256,7 +128326,7 @@ class SceneGraphCollection {
128256
128326
  if (needsToBeInitialized && !script.initialized)
128257
128327
  continue;
128258
128328
  const sgNode = script.parentItem;
128259
- if (sgNode.isEnabled() && sgNode.allAncestorsAreActive())
128329
+ if (sgNode.isActive() && sgNode.allAncestorsAreActive())
128260
128330
  func(script);
128261
128331
  }
128262
128332
  catch (err) {
@@ -133652,7 +133722,7 @@ class RtSceneObject extends RtBase {
133652
133722
  if (!obj)
133653
133723
  return false;
133654
133724
  if (obj instanceof SgItem) {
133655
- return obj.isEnabled();
133725
+ return obj.isActive();
133656
133726
  }
133657
133727
  return false;
133658
133728
  }
@@ -134353,7 +134423,7 @@ class RtSgAudio extends RtSceneObject {
134353
134423
  }
134354
134424
  play(params) {
134355
134425
  const sgaudio = this._getParamSceneObject(params.obj, SgAudio, false);
134356
- if (sgaudio && sgaudio.isEnabled()) {
134426
+ if (sgaudio && sgaudio.isActive()) {
134357
134427
  const audio = sgaudio.getObject();
134358
134428
  if (audio) {
134359
134429
  if (audio.isPlaying && params.force)
@@ -148831,6 +148901,20 @@ const SUPPORTED_TYPES = {
148831
148901
  defaultAction: "Use",
148832
148902
  actions: ["Skip", "Use"]
148833
148903
  },
148904
+ "sog": {
148905
+ name: "SOG",
148906
+ itemType: "Gaussian Splats",
148907
+ folderName: "gaussiansplats",
148908
+ defaultAction: "Use",
148909
+ actions: ["Skip", "Use"]
148910
+ },
148911
+ "spz": {
148912
+ name: "SPZ",
148913
+ itemType: "Gaussian Splats",
148914
+ folderName: "gaussiansplats",
148915
+ defaultAction: "Use",
148916
+ actions: ["Skip", "Use"]
148917
+ },
148834
148918
  "material": {
148835
148919
  name: "JSON",
148836
148920
  itemType: "Material",