wonder.js
Version:
58 lines (53 loc) • 3.4 kB
JavaScript
'use strict';
var ArrayService$Wonderjs = require("../../../atom/ArrayService.js");
var ArrayService$WonderCommonlib = require("wonder-commonlib/lib/js/src/ArrayService.js");
var OperateRenderMainService$Wonderjs = require("./OperateRenderMainService.js");
var GetComponentGameObjectService$Wonderjs = require("../../../record/main/gameObject/GetComponentGameObjectService.js");
var HasComponentGameObjectService$Wonderjs = require("../../../record/main/gameObject/HasComponentGameObjectService.js");
var RenderObjectBufferTypeArrayService$Wonderjs = require("../../../record/main/render/RenderObjectBufferTypeArrayService.js");
function _setSourceInstance(index, uid, sourceInstanceIndices, gameObjectRecord) {
var match = GetComponentGameObjectService$Wonderjs.getSourceInstanceComponent(uid, gameObjectRecord);
if (match !== undefined) {
return RenderObjectBufferTypeArrayService$Wonderjs.setComponent(index, match, sourceInstanceIndices);
} else {
return sourceInstanceIndices;
}
}
function setData(renderGameObjectArray, unsafeGetMaterialComponentFunc, renderObjectRecord, state) {
var gameObjectRecord = state[/* gameObjectRecord */10];
var match = OperateRenderMainService$Wonderjs.hasCameraRecord(state);
var renderGameObjectArray$1 = match ? renderGameObjectArray : /* array */[];
var match$1 = ArrayService$WonderCommonlib.reduceOneParami((function (dataTuple, uid, index) {
var geometryIndex = GetComponentGameObjectService$Wonderjs.unsafeGetGeometryComponent(uid, gameObjectRecord);
var materialIndex = unsafeGetMaterialComponentFunc(uid, gameObjectRecord);
return /* tuple */[
RenderObjectBufferTypeArrayService$Wonderjs.setComponent(index, GetComponentGameObjectService$Wonderjs.unsafeGetTransformComponent(uid, gameObjectRecord), dataTuple[0]),
RenderObjectBufferTypeArrayService$Wonderjs.setComponent(index, materialIndex, dataTuple[1]),
RenderObjectBufferTypeArrayService$Wonderjs.setComponent(index, GetComponentGameObjectService$Wonderjs.unsafeGetMeshRendererComponent(uid, gameObjectRecord), dataTuple[2]),
RenderObjectBufferTypeArrayService$Wonderjs.setComponent(index, geometryIndex, dataTuple[3]),
_setSourceInstance(index, uid, dataTuple[4], gameObjectRecord),
ArrayService$Wonderjs.push(index, dataTuple[5])
];
}), /* tuple */[
renderObjectRecord[/* transformIndices */2],
renderObjectRecord[/* materialIndices */3],
renderObjectRecord[/* meshRendererIndices */4],
renderObjectRecord[/* geometryIndices */5],
renderObjectRecord[/* sourceInstanceIndices */6],
/* array */[]
], renderGameObjectArray$1.filter((function (uid) {
return HasComponentGameObjectService$Wonderjs.hasGeometryComponent(uid, gameObjectRecord);
})));
return /* record */[
/* buffer */renderObjectRecord[/* buffer */0],
/* renderIndexArray */match$1[5],
/* transformIndices */match$1[0],
/* materialIndices */match$1[1],
/* meshRendererIndices */match$1[2],
/* geometryIndices */match$1[3],
/* sourceInstanceIndices */match$1[4]
];
}
exports._setSourceInstance = _setSourceInstance;
exports.setData = setData;
/* ArrayService-Wonderjs Not a pure module */