Skip to content

Commit 441d38e

Browse files
committed
saving light extensions for next PR
1 parent ed6daf4 commit 441d38e

File tree

2 files changed

+1
-120
lines changed

2 files changed

+1
-120
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## Unreleased
99

1010
### Added
11-
* Added gltf extensions: `KHR_materials_transmission`, `KHR_materials_specular`, `KHR_materials_ior`, `KHR_materials_clearcoat`, `KHR_Texture_Transform`, `KHR_materials_pbrSpecularGlossiness`, `KHR_lights_punctual`, `Light`, `LightSpot`
11+
* Added gltf extensions: `KHR_materials_transmission`, `KHR_materials_specular`, `KHR_materials_ior`, `KHR_materials_clearcoat`, `KHR_Texture_Transform`, `KHR_materials_pbrSpecularGlossiness`
1212
* Added `GLTFContent.check_extensions_texture_recursively`
1313
* Added `GLTFContent.get_node_by_name`, `GLTFContent.get_material_index_by_name`
1414
* Added `GLTFContent.add_material`, `GLTFContent.add_texture`, `GLTFContent.add_image`

src/compas/files/gltf/extensions.py

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -307,130 +307,11 @@ def from_data(cls, dct):
307307
)
308308

309309

310-
class LightSpot(BaseGLTFDataClass):
311-
"""LightSpot
312-
313-
https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual/schema/light.spot.schema.json
314-
"""
315-
316-
def __init__(
317-
self,
318-
innerConeAngle=None,
319-
outerConeAngle=None,
320-
extensions=None,
321-
extras=None,
322-
):
323-
super(LightSpot, self).__init__(extras, extensions)
324-
self.innerConeAngle = innerConeAngle # Angle in radians from centre of spotlight where falloff ends.
325-
self.outerConeAngle = outerConeAngle # Angle in radians from centre of spotlight where falloff begins.
326-
327-
def to_data(self, texture_index_by_key, **kwargs):
328-
dct = super(LightSpot, self).to_data(texture_index_by_key, **kwargs)
329-
if self.innerConeAngle is not None:
330-
dct["innerConeAngle"] = self.innerConeAngle
331-
if self.outerConeAngle is not None:
332-
dct["outerConeAngle"] = self.outerConeAngle
333-
return dct
334-
335-
@classmethod
336-
def from_data(cls, dct):
337-
if dct is None:
338-
return None
339-
return cls(
340-
innerConeAngle=dct.get("innerConeAngle"), outerConeAngle=dct.get("outerConeAngle"), extensions=cls.extensions_from_data(dct.get("extensions")), extras=dct.get("extras")
341-
)
342-
343-
344-
class LightType(object):
345-
"""Specifies the light type."""
346-
347-
directional = "directional"
348-
point = "point"
349-
spot = "spot"
350-
351-
352-
class Light(BaseGLTFDataClass):
353-
"""A directional, point, or spot light.
354-
355-
https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual/schema/light.schema.json
356-
"""
357-
358-
key = "KHR_lights_punctual"
359-
360-
def __init__(self, color=None, intensity=None, spot=None, type=None, range=None, name=None, extensions=None, extras=None):
361-
super(Light, self).__init__(extras, extensions)
362-
self.color = color # [1, 1, 1]
363-
self.intensity = intensity # 1.0
364-
self.spot = spot # LightSpot
365-
self.type = type or LightType.directional
366-
self.range = range # A distance cutoff at which the light's intensity may be considered to have reached zero.
367-
self.name = name
368-
369-
def to_data(self, texture_index_by_key, **kwargs):
370-
dct = super(Light, self).to_data(texture_index_by_key, **kwargs)
371-
if self.color is not None:
372-
dct["color"] = self.color
373-
if self.intensity is not None:
374-
dct["intensity"] = self.intensity
375-
if self.spot is not None:
376-
dct["spot"] = self.spot.to_data()
377-
if self.type is not None:
378-
dct["type"] = self.type
379-
if self.range is not None:
380-
dct["range"] = self.range
381-
if self.name is not None:
382-
dct["name"] = self.name
383-
return dct
384-
385-
@classmethod
386-
def from_data(cls, dct):
387-
if dct is None:
388-
return None
389-
return cls(
390-
color=dct.get("color"),
391-
intensity=dct.get("intensity"),
392-
spot=LightSpot.from_data(dct.get("spot")),
393-
type=dct.get("type"),
394-
range=dct.get("range"),
395-
name=dct.get("name"),
396-
extensions=cls.extensions_from_data(dct.get("extensions")),
397-
extras=dct.get("extras"),
398-
)
399-
400-
401-
class KHR_lights_punctual(BaseGLTFDataClass):
402-
""""""
403-
404-
key = "KHR_lights_punctual"
405-
406-
def __init__(
407-
self,
408-
lights=None,
409-
extensions=None,
410-
extras=None,
411-
):
412-
super(KHR_lights_punctual, self).__init__(extras, extensions)
413-
self.lights = lights
414-
415-
def to_data(self, texture_index_by_key, **kwargs):
416-
dct = super(KHR_lights_punctual, self).to_data(texture_index_by_key, **kwargs)
417-
if self.lights is not None:
418-
dct["lights"] = self.lights
419-
return dct
420-
421-
@classmethod
422-
def from_data(cls, dct):
423-
if dct is None:
424-
return None
425-
return cls(lights=dct.get("lights"), extensions=cls.extensions_from_data(dct.get("extensions")), extras=dct.get("extras"))
426-
427-
428310
SUPPORTED_EXTENSIONS = {
429311
KHR_materials_transmission.key: KHR_materials_transmission,
430312
KHR_materials_clearcoat.key: KHR_materials_clearcoat,
431313
KHR_Texture_Transform.key: KHR_Texture_Transform,
432314
KHR_materials_pbrSpecularGlossiness.key: KHR_materials_pbrSpecularGlossiness,
433315
KHR_materials_specular.key: KHR_materials_specular,
434316
KHR_materials_ior.key: KHR_materials_ior,
435-
KHR_lights_punctual.key: KHR_lights_punctual,
436317
}

0 commit comments

Comments
 (0)