Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// console.log(`GraphYAxisGl ctor`);
super(props);
const { width } = this.graphFixedLayoutInfo;
this.lineDashedMaterial = new THREE.LineDashedMaterial({
color: convertHexColorStringToInt(this.theme.graphLineStrokeColor),
linewidth: 1.5 * this.pixelRatio,
dashSize: 5 * this.pixelRatio,
gapSize: 4 * this.pixelRatio,
});
const leftMargin = 30;
const rightMargin = 4;
const xStart = leftMargin * this.pixelRatio;
const xEnd = width * this.pixelRatio - rightMargin * this.pixelRatio;
this.lineGeometry = new THREE.Geometry();
this.lineGeometry.vertices.push(
new THREE.Vector3(xStart, 0, 0),
new THREE.Vector3(xEnd, 0, 0)
);
this.yAxisBGBoundaryValueLines = new Map();
this.yAxisLabelTextMeshes = new Map();
}
constructor(props) {
super(props);
// console.log(`GraphNoteEventGl ctor`);
const tickLineHeight = this.graphFixedLayoutInfo.height;
this.tickLineGeometry = new THREE.Geometry();
this.tickLineGeometry.vertices.push(new THREE.Vector3(0, 0, 0));
this.tickLineGeometry.vertices.push(
new THREE.Vector3(0, -tickLineHeight * this.pixelRatio, 0)
);
this.tickLineMaterial = new THREE.LineBasicMaterial({
color: 0x000000,
linewidth: 1.5 * this.pixelRatio,
});
const tickTriangleWidth = 16;
const tickTriangleHeight = Math.sqrt(
tickTriangleWidth * tickTriangleWidth - tickTriangleWidth / 2
);
const tickTriangleShape = new THREE.Shape();
tickTriangleShape.moveTo(-tickTriangleWidth / 2 * this.pixelRatio, 0);
tickTriangleShape.lineTo(tickTriangleWidth / 2 * this.pixelRatio, 0);
mesh.traverse(async child => {
if (child instanceof THREE.Mesh) {
console.warn('child', child);
/// Smooth geometry
const tempGeo = new THREE.Geometry().fromBufferGeometry(child.geometry);
tempGeo.mergeVertices();
// after only mergeVertices my textrues were turning black so this fixed normals issues
tempGeo.computeVertexNormals();
tempGeo.computeFaceNormals();
child.geometry = new THREE.BufferGeometry().fromGeometry(tempGeo);
child.material.shading = THREE.SmoothShading;
child.material.side = THREE.FrontSide;
/// Apply other maps - maybe this is supposed to be automatic :[
child.material.normalMap = await ExpoTHREE.loadAsync(
model['B-AO_iOS_HERO_Bruce_Wayne_Batman_Arkham_Origins_Body_N.png']
);
child.material.specularMap = await ExpoTHREE.loadAsync(
model['B-AO_iOS_HERO_Bruce_Wayne_Batman_Arkham_Origins_Body_S.png']
mesh.traverse(async child => {
if (child instanceof THREE.Mesh) {
/// Smooth geometry
const tempGeo = new THREE.Geometry().fromBufferGeometry(child.geometry);
tempGeo.mergeVertices();
// after only mergeVertices my textrues were turning black so this fixed normals issues
tempGeo.computeVertexNormals();
tempGeo.computeFaceNormals();
child.geometry = new THREE.BufferGeometry().fromGeometry(tempGeo);
child.material.side = THREE.FrontSide;
/// Apply other maps - maybe this is supposed to be automatic :[
child.material.normalMap = await ExpoTHREE.loadAsync(
model['B-AO_iOS_HERO_Bruce_Wayne_Batman_Arkham_Origins_Body_N.png']
);
child.material.specularMap = await ExpoTHREE.loadAsync(
model['B-AO_iOS_HERO_Bruce_Wayne_Batman_Arkham_Origins_Body_S.png']
);
renderSuppressedLine() {
if (this.suppressedLinePath) {
const points = this.suppressedLinePath.getPoints();
const geometry = new THREE.Geometry().setFromPoints(points);
const { contentOffsetX, pixelsPerSecond } = this;
const line = new THREE.Line(geometry, this.suppressedLineMaterial);
this.updateSuppressedLineMaterial();
this.addAutoScrollableObjectToScene(this.scene, line, {
x: 0,
y: this.yAxisBottomOfBasal,
z: this.zStart,
contentOffsetX,
pixelsPerSecond,
shouldScrollX: true,
shouldScaleX: true,
});
// NOTE: computeLineDistances is Necessary to compute dashed material for the line, else the
// line won't be dashed
line.computeLineDistances();
setupLine = () => {
const geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3());
geometry.vertices.push(new THREE.Vector3(1, 1, 1));
geometry.verticesNeedUpdate = true;
geometry.dynamic = true;
this.line = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({
color: 0x00ff00,
opacity: 1,
linewidth: 7,
side: THREE.DoubleSide,
linecap: 'round',
})
);
/// https://stackoverflow.com/questions/36497763/three-js-line-disappears-if-one-point-is-outside-of-the-cameras-view
init = async () => {
//make falling particles
this.particlesGeometry = new THREE.Geometry();
for (let i = 0; i < PARTICLES_COUNT; i++) {
this.particlesGeometry.vertices.push(
new THREE.Vector3(
randomRange(-Settings.FLOOR_WIDTH / 2, Settings.FLOOR_WIDTH / 2),
randomRange(Settings.PARTICLES_BOTTOM, Settings.PARTICLES_TOP),
randomRange(-Settings.FLOOR_DEPTH / 2, Settings.FLOOR_DEPTH / 2),
),
);
}
const particlesMaterial = new THREE.PointsMaterial({
size: 50,
// sizeAttenuation: true,
map: await ExpoTHREE.loadAsync(Assets.images['particle.png']),
transparent: true,
function Mesh(data, mesher, scaleFactor, mesherExtraData) {
this.data = data;
var geometry = (this.geometry = new THREE.Geometry());
this.scale = scaleFactor || new THREE.Vector3(10, 10, 10);
var result = mesher(data.voxels, data.dims, mesherExtraData);
this.meshed = result;
geometry.vertices.length = 0;
geometry.faces.length = 0;
for (var i = 0; i < result.vertices.length; ++i) {
var q = result.vertices[i];
geometry.vertices.push(new THREE.Vector3(q[0], q[1], q[2]));
}
for (var i = 0; i < result.faces.length; ++i) {
geometry.faceVertexUvs[0].push(this.faceVertexUv(i));