UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

44 lines (35 loc) 1.01 kB
import { AbstractRenderAdapter } from "./AbstractRenderAdapter.js"; import { SGThreeObjectCache } from "../SGThreeObjectCache.js"; export class GenericRendererAdapter extends AbstractRenderAdapter { constructor() { super(); /** * * @type {SGThreeObjectCache} * @private */ this.__cache = SGThreeObjectCache.INSTANCE; } /** * * @param {THREE.WebGLRenderer} renderer * @param {CameraView} view */ build_start(renderer, view) { this.clear(); } add(sg) { /** * * @type {THREE.Object3D} */ const object = this.__cache.get(sg); const source = sg.transform; const destination = object.matrixWorld.elements; // copy transform matrix for (let i = 0; i < 16; i++) { destination[i] = source[i]; } this.__objects[this.__object_count++] = object; } }