@tomorrowevening/hermes 0.0.26 → 0.0.27

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.
@@ -275,27 +275,119 @@ export function inspectMaterialItems(material: RemoteMaterial, object: RemoteObj
275
275
  title: prettyName(n),
276
276
  type: 'image',
277
277
  value: propValue.value.src,
278
- onChange: (prop: string, value: any) => {
278
+ onChange: (_: string, newValue: any) => {
279
279
  three.createTexture(object.uuid, `material.${i}.${n}.value`, value);
280
280
  // Local update
281
281
  const child = three.scene?.getObjectByProperty('uuid', object.uuid);
282
282
  if (child !== undefined) {
283
- textureFromSrc(value).then((texture: Texture) => {
283
+ textureFromSrc(newValue).then((texture: Texture) => {
284
284
  setItemProps(child, `material.${i}.${n}.value`, texture);
285
285
  });
286
286
  }
287
287
  },
288
288
  });
289
+ } else if (i === 'uniforms') {
290
+ const pv = propValue.value;
291
+ // Probably in Uniforms
292
+ const makeFloat = (vTitle: string, vProp: string, floatValue: number) => {
293
+ return {
294
+ title: vTitle,
295
+ type: 'number',
296
+ value: floatValue,
297
+ onChange: (_: string, updatedValue: any) => {
298
+ const id = `material.uniforms.${n}.value.${vProp}`;
299
+ three.updateObject(object.uuid, id, updatedValue);
300
+ // Local update
301
+ const child = three.scene?.getObjectByProperty('uuid', object.uuid);
302
+ if (child !== undefined) setItemProps(child, id, updatedValue);
303
+ },
304
+ };
305
+ };
306
+ if (typeof propValue.value === 'number') {
307
+ subChildren.push({
308
+ title: n,
309
+ type: 'number',
310
+ value: propValue.value,
311
+ onChange: (prop: string, value: any) => {
312
+ const id = `material.${i}.${prop}.value`;
313
+ three.updateObject(object.uuid, id, value);
314
+ // Local update
315
+ const child = three.scene?.getObjectByProperty('uuid', object.uuid);
316
+ if (child !== undefined) setItemProps(child, id, value);
317
+ },
318
+ });
319
+ } else if (pv['r'] !== undefined && pv['g'] !== undefined && pv['b'] !== undefined) {
320
+ subChildren.push({
321
+ title: n,
322
+ type: 'color',
323
+ value: propValue.value,
324
+ onChange: (prop: string, value: any) => {
325
+ const newValue = new Color(value);
326
+ const id = `material.${i}.${prop}.value`;
327
+ three.updateObject(object.uuid, id, newValue);
328
+ // Local update
329
+ const child = three.scene?.getObjectByProperty('uuid', object.uuid);
330
+ if (child !== undefined) setItemProps(child, id, newValue);
331
+ },
332
+ });
333
+ } else if (pv['x'] !== undefined && pv['y'] !== undefined && pv['z'] === undefined && pv['w'] === undefined) {
334
+ subChildren.push(
335
+ {
336
+ title: n,
337
+ items: [
338
+ makeFloat('X', 'x', propValue.value.x),
339
+ makeFloat('Y', 'y', propValue.value.y),
340
+ ]
341
+ }
342
+ );
343
+ } else if (pv['x'] !== undefined && pv['y'] !== undefined && pv['z'] !== undefined && pv['w'] === undefined) {
344
+ subChildren.push(
345
+ {
346
+ title: n,
347
+ items: [
348
+ makeFloat('X', 'x', propValue.value.x),
349
+ makeFloat('Y', 'y', propValue.value.y),
350
+ makeFloat('Z', 'z', propValue.value.z),
351
+ ]
352
+ }
353
+ );
354
+ } else if (pv['x'] !== undefined && pv['y'] !== undefined && pv['z'] !== undefined && pv['w'] !== undefined) {
355
+ subChildren.push(
356
+ {
357
+ title: n,
358
+ items: [
359
+ makeFloat('X', 'x', propValue.value.x),
360
+ makeFloat('Y', 'y', propValue.value.y),
361
+ makeFloat('Z', 'z', propValue.value.z),
362
+ makeFloat('W', 'w', propValue.value.w),
363
+ ]
364
+ }
365
+ );
366
+ } else if (pv['elements'] !== undefined) {
367
+ const matrix = pv.elements;
368
+ const matrixChildren: any[] = [];
369
+ for (let i = 0; i < matrix.length; i++) {
370
+ matrixChildren.push(makeFloat(i.toString(), i.toString(), matrix[i]));
371
+ }
372
+ subChildren.push(
373
+ {
374
+ title: n,
375
+ items: matrixChildren
376
+ }
377
+ );
378
+ } else {
379
+ console.log('>>> need to add this format:', n, pv);
380
+ }
289
381
  } else {
290
382
  subChildren.push({
291
383
  title: n,
292
384
  type: `${typeof propValue.value}`,
293
385
  value: propValue.value,
294
- onChange: (prop: string, value: any) => {
295
- three.updateObject(object.uuid, `material.${i}.${n}.value`, value);
386
+ onChange: (_: string, newValue: any) => {
387
+ three.updateObject(object.uuid, `material.${i}.${n}.value`, newValue);
296
388
  // Local update
297
389
  const child = three.scene?.getObjectByProperty('uuid', object.uuid);
298
- if (child !== undefined) setItemProps(child, `material.${i}.${n}.value`, value);
390
+ if (child !== undefined) setItemProps(child, `material.${i}.${n}.value`, newValue);
299
391
  },
300
392
  });
301
393
  }