@webviz/subsurface-viewer
Version:
3D visualization component for subsurface reservoir data
45 lines • 1.68 kB
JavaScript
import { COORDINATE_SYSTEM, Layer, project32 } from "@deck.gl/core";
import { Geometry, Model } from "@luma.gl/engine";
import { precisionForTests } from "../shader_modules/test-precision/precisionForTests";
import fragmentShader from "./box.fs.glsl";
import vertexShader from "./box.vs.glsl";
const defaultProps = {
name: "Box",
id: "box-layer",
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
lines: [],
color: [0, 0, 0, 1],
};
export default class BoxLayer extends Layer {
initializeState(context) {
this.setState(this._getModels(context.device));
}
shouldUpdateState() {
return true;
}
updateState({ context }) {
this.setState(this._getModels(context.device));
}
_getModels(device) {
const color = this.props.color.map((x) => (x !== null && x !== void 0 ? x : 0) / 255);
const grids = new Model(device, Object.assign(Object.assign({ id: `${this.props.id}-grids` }, super.getShaders({
vs: vertexShader,
fs: fragmentShader,
modules: [project32, precisionForTests],
})), { uniforms: { uColor: Array.from(color) }, geometry: new Geometry({
topology: "line-list",
attributes: {
positions: new Float32Array(this.props.lines),
},
vertexCount: this.props.lines.length / 3,
}), isInstanced: false }));
return {
model: grids,
models: [grids].filter(Boolean),
modelsByName: { grids },
};
}
}
BoxLayer.layerName = "BoxLayer";
BoxLayer.defaultProps = defaultProps;
//# sourceMappingURL=boxLayer.js.map