GLTFLightsExtension constructor

GLTFLightsExtension(
  1. dynamic parser
)

Implementation

GLTFLightsExtension(this.parser) {
  name = gltfExtensions["KHR_LIGHTS_PUNCTUAL"]!;

  // Object3D instance caches
  cache = {"refs": {}, "uses": {}};

  createNodeAttachment = (nodeIndex) {
    var self = this;
    var parser = this.parser;
    var json = parser.json;
    Map<String, dynamic> nodeDef = json["nodes"][nodeIndex];

    // var lightDef = ( nodeDef.extensions && nodeDef.extensions[ this.name ] ) ?? {};
    var lightDef = {};
    if (nodeDef["extensions"] != null && nodeDef["extensions"][name] != null) {
      lightDef = nodeDef["extensions"][name];
    }

    var lightIndex = lightDef["light"];

    if (lightIndex == null) return null;

    final light = _loadLight(lightIndex);

    return parser._getNodeRef(self.cache, lightIndex, light);
  };
}