Back to the Shapespark home page

JSON script and the dealing with lights

Hi.
We have a JSON script that creates lights in Shapespark. Unfortunately, all existing lights, even the one created in Shapespark, will be deleted when we update the scene with the JSON. Is there a way that the script can ignore existing lights?

Hi!

The lights created in Shapespark shouldn’t be deleted when the scene is updated, and I cannot reproduce such a behavior. Could you re-check it?

For lights specified only in JSON (not created in the Shapespark application), what do you mean by “deleted”? Do you mean that a scene update may overwrite changes to light settings (eg. strength) made manually in the editor? Or do you mean that some lights disappear? If the former, then one solution is to export the light strength from the 3D modeling tool only when the model is exported for the first time, and skip this property in the subsequent exports.

Hey!
I tested it again, but this time the lights I created in Shapespark were not deleted after the re-import. So maybe I deleted them accidentally last time.

When I import the lights from 3DS Max with JSON I have two cases:

  1. I adjust the imported lights (strength, IES, orientation) inside Shapespark. After a re-import, the settings are overwritten by the script and set back to the settings as I have them in 3DS Max.
  2. When I re-import the scene from 3DS Max with the JSON script but exclude the lights, all lights I imported before are deleted.

Thanks for clarification, @tim.

There is one issue with ignoring existing lights on import. If you modify some light property, say strength, in 3ds Max, not in Shapespark, then this modification will not be imported to Shapespark. Do you think it will be the case that a user of your exporter modifies a light both in 3ds Max and in Shapespark?

I think the first setup will be done in 3DS Max but the final modification will always be done in Shapespark.

We’ll add a mechanism to prevent the light settings modified in Shapespark from being overwritten when the scene is re-imported with extras.json. However, I am not sure we’ll be able to include this change in the next release that will be out soon - in this case it will be included in the following one.

For now, as a workaround you could make the 3ds Max exporter script to have two modes: export for initial import, and export for re-import (update). In the latter case the exporter could omit certain light settings - for each light it would include only name and instances, for example:

"lights": [
  {
    "name": "light 1",
    "instances": [
      {
        "position": [1, 1, 1],
        "rotation": [0, -90]
      }
    ]
  }
]

Lack of properties like strength, type etc. will cause the values in Shapespark to be kept on re-import.

Thank you @wojtek
We will test it and see how it goes.