teleportxr 1.0.39 → 1.0.40

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/client/client.js CHANGED
@@ -131,15 +131,15 @@ class Client {
131
131
  if(this.scene.backgroundTexturePath&&this.scene.backgroundTexturePath!="")
132
132
  {
133
133
  this.setupCommand.BackgroundMode_backgroundMode=BackgroundMode.TEXTURE;
134
- this.setupCommand.uid_backgroundTexture=resources.AddTexture(this.scene.backgroundTexturePath);
134
+ this.setupCommand.uid_backgroundTexture=resources.GetOrAddTexture(this.scene.backgroundTexturePath);
135
135
  }
136
136
  if(this.scene.diffuseCubemapPath&&this.scene.diffuseCubemapPath!="")
137
137
  {
138
- this.clientDynamicLighting.uid_diffuse_cubemap_texture_uid=resources.AddTexture(this.scene.diffuseCubemapPath);
138
+ this.clientDynamicLighting.uid_diffuse_cubemap_texture_uid=resources.GetOrAddTexture(this.scene.diffuseCubemapPath);
139
139
  }
140
140
  if(this.scene.specularCubemapPath&&this.scene.specularCubemapPath!="")
141
141
  {
142
- this.clientDynamicLighting.uid_specular_cubemap_texture_uid=resources.AddTexture(this.scene.specularCubemapPath);
142
+ this.clientDynamicLighting.uid_specular_cubemap_texture_uid=resources.GetOrAddTexture(this.scene.specularCubemapPath);
143
143
  }
144
144
  }
145
145
 
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "name": "teleportxr",
17
17
  "description": "Teleport Spatial Server on node.js",
18
- "version": "1.0.39",
18
+ "version": "1.0.40",
19
19
  "repository": {
20
20
  "type": "git",
21
21
  "url": "git+https://github.com/simul/teleport-nodejs.git"
package/scene/node.js CHANGED
@@ -247,7 +247,7 @@ class Node {
247
247
  return Node.sizeof();
248
248
  }
249
249
  setMeshComponent(mesh_url) {
250
- resources.AddMesh(mesh_url);
250
+ resources.GetOrAddMesh(mesh_url);
251
251
  this.components.forEach((component) => {
252
252
  if (component.getType() == NodeDataType.Mesh) {
253
253
  component.meshUrl = mesh_url;
@@ -150,7 +150,10 @@ function AddTypedResource(typename, path) {
150
150
  return uid;
151
151
  }
152
152
 
153
- function AddResourceFromUrl(type, url) {
153
+ function GetOrAddResourceFromUrl(type, url) {
154
+ if (Resource.pathToUid.has(url)) {
155
+ return Resource.pathToUid.get(url);
156
+ }
154
157
  var uid = core.generateUid();
155
158
  var res = null;
156
159
  switch (type) {
@@ -159,7 +162,7 @@ function AddResourceFromUrl(type, url) {
159
162
  throw new Error(
160
163
  "Type ",
161
164
  type,
162
- " can't be instantiated with AddResourceFromUrl()."
165
+ " can't be instantiated with GetOrAddResourceFromUrl()."
163
166
  );
164
167
  break;
165
168
  default:
@@ -186,7 +189,7 @@ function GetOrAddResourceUidFromUrl(type, url){
186
189
  return uid;
187
190
  if(!url)
188
191
  return 0;
189
- return AddResourceFromUrl(type, url);
192
+ return GetOrAddResourceFromUrl(type, url);
190
193
  }
191
194
 
192
195
  function GetResourceFromUrl(url) {
@@ -202,14 +205,14 @@ function GetResourceFromUid(uid) {
202
205
  return res;
203
206
  }
204
207
 
205
- //! Add the texture url as a resource.
206
- function AddTexture(url) {
207
- return AddResourceFromUrl(core.GeometryPayloadType.TexturePointer, url);
208
+ //! Get or add the texture url as a resource.
209
+ function GetOrAddTexture(url) {
210
+ return GetOrAddResourceFromUrl(core.GeometryPayloadType.TexturePointer, url);
208
211
  }
209
212
 
210
- //! Add the texture url as a resource.
211
- function AddMesh(url) {
212
- return AddResourceFromUrl(core.GeometryPayloadType.MeshPointer, url);
213
+ //! Get or add the mesh url as a resource.
214
+ function GetOrAddMesh(url) {
215
+ return GetOrAddResourceFromUrl(core.GeometryPayloadType.MeshPointer, url);
213
216
  }
214
217
 
215
218
  function AddFontAtlas(path) {
@@ -233,8 +236,8 @@ module.exports = {
233
236
  GetResourceUidFromUrl,
234
237
  GetOrAddResourceUidFromUrl,
235
238
  GetResourceFromUid,
236
- AddTexture,
237
- AddMesh,
239
+ GetOrAddTexture,
240
+ GetOrAddMesh,
238
241
  AddFontAtlas,
239
242
  AddTextCanvas,
240
243
  AddTypedResource,
package/scene/scene.js CHANGED
@@ -176,17 +176,17 @@ class Scene {
176
176
  if(j.environment.background_texture)
177
177
  {
178
178
  this.backgroundTexturePath=j.environment.background_texture;
179
- resources.AddTexture(this.backgroundTexturePath);
179
+ resources.GetOrAddTexture(this.backgroundTexturePath);
180
180
  }
181
181
  if(j.environment.diffuse_cubemap)
182
182
  {
183
183
  this.diffuseCubemapPath=j.environment.diffuse_cubemap;
184
- resources.AddTexture(this.diffuseCubemapPath);
184
+ resources.GetOrAddTexture(this.diffuseCubemapPath);
185
185
  }
186
186
  if(j.environment.specular_cubemap)
187
187
  {
188
188
  this.specularCubemapPath=j.environment.specular_cubemap;
189
- resources.AddTexture(this.specularCubemapPath);
189
+ resources.GetOrAddTexture(this.specularCubemapPath);
190
190
  }
191
191
  }
192
192
  if(j.font_atlases)