Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor() {
super();
// FIXME: replace identity() with create()
this.matrix = identity([]);
this.matrixWorld = identity([]);
this.position = [0, 0, 0];
this.scale = [1, 1, 1];
this.quaternion = [0, 0, 0, 1];
this.children = [];
this.matrixAutoUpdate = true;
this.matrixWorldAutoUpdate = true;
}
unormal: (context, props) => {
const model = props.model || props.transforms.matrix
// console.log('here', model)
// const model = mat4.identity([])
const modelViewMatrix = mat4.multiply(mat4.create(), model, props.camera.view)
const normalMatrix = mat4.create()
mat4.invert(normalMatrix, modelViewMatrix)
mat4.transpose(normalMatrix, normalMatrix)
return normalMatrix
}
},
return (props) => {
const defaults = {
model: mat4.identity([])
}
props = Object.assign({}, defaults, props)
return single([
{ color: xColor, model: mat4.multiply(mat4.create(), props.model, xAxisModel) }, // X
{ color: yColor, model: mat4.multiply(mat4.create(), props.model, yAxisModel) }, // Y
{ color: zColor, model: mat4.multiply(mat4.create(), props.model, zAxisModel) } // Z
])
}
}
return (props) => {
const defaults = {
model: mat4.identity([])
}
props = Object.assign({}, defaults, props)
return single([
{ color: xColor, model: mat4.multiply(mat4.create(), props.model, xAxisModel) }, // X
{ color: yColor, model: mat4.multiply(mat4.create(), props.model, yAxisModel) }, // Y
{ color: zColor, model: mat4.multiply(mat4.create(), props.model, zAxisModel) } // Z
])
}
}
function paint( xRot, yRot ) {
if (!initialized) { return }
if (polyBuffersOutdated) {
// buffers out of sync w/ arrays since last mutation wasn't kept
vertBuffer.update( polys.vertArr )
colBuffer.update( polys.colArr )
}
// rotation matrix (simple Euler angles)
camMatrix = mat4.create()
mat4.rotateY(camMatrix, camMatrix, yRot)
mat4.rotateX(camMatrix, camMatrix, xRot)
// paint polygons
drawData( SCREEN, perspective, camMatrix )
}
function paint(xRot, yRot) {
if (polyBuffersOutdated) {
// buffers out of sync w/ arrays since last mutation wasn't kept
vertBuffer.update(polys.getVertArray())
colBuffer.update(polys.getColorArray())
}
// rotation matrix (simple Euler angles)
camMatrix = mat4.create()
mat4.rotateY(camMatrix, camMatrix, xRot || 0)
mat4.rotateX(camMatrix, camMatrix, yRot || 0)
// paint polygons
drawData(null, perspective, camMatrix)
}
function centerGeometry(geo, scale) {
// Calculate the bounding box.
var bb = boundingBox(geo.positions);
// Translate the geometry center to the origin.
var translate = [-0.5 * (bb[0][0] + bb[1][0]), -0.5 * (bb[0][1] + bb[1][1]), -0.5 * (bb[0][2] + bb[1][2])];
var m = mat4.create();
mat4.scale(m, m, [scale, scale, scale]);
mat4.translate(m, m, translate);
geo.positions = transform(geo.positions, m)
}
function setupCube ({center, fbo}, block) {
mat4.perspective(
cubeProps.projection,
Math.PI / 2.0,
1.0,
0.25,
1000.0)
cubeProps.cubeFBO = fbo
cubeProps.center = center
// execute `setupCubeFace` 6 times, where each time will be
// a different batch, and the batchIds of the 6 batches will be
// 0, 1, 2, 3, 4, 5
setupCubeFace.call(cubeProps, 6, block)
}
model: ({model}, {scale = 1, translate = 0}) => (
mat4.scale([], mat4.translate([], model, [0, translate, 0]), [scale, scale, scale])
)
},
return (_, {model, headModel}) => mat4.multiply(out, model, headModel)
})()