Пример #1
0
        protected virtual GameObject CreateNode(GLTF.Schema.Node node)
        {
            var nodeObj = new GameObject(node.Name ?? "GLTFNode");

            Vector3    position;
            Quaternion rotation;
            Vector3    scale;

            node.GetUnityTRSProperties(out position, out rotation, out scale);
            nodeObj.transform.localPosition = position;
            nodeObj.transform.localRotation = rotation;
            nodeObj.transform.localScale    = scale;

            // TODO: Add support for skin/morph targets
            if (node.Mesh != null)
            {
                CreateMeshObject(node.Mesh.Value, nodeObj.transform, node.Mesh.Id);
            }

            /* TODO: implement camera (probably a flag to disable for VR as well)
             * if (camera != null)
             * {
             *      GameObject cameraObj = camera.Value.Create();
             *      cameraObj.transform.parent = nodeObj.transform;
             * }
             */

            if (node.Children != null)
            {
                foreach (var child in node.Children)
                {
                    var childObj = CreateNode(child.Value);
                    childObj.transform.SetParent(nodeObj.transform, false);
                }
            }

            return(nodeObj);
        }