Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props) {
// console.log(`GraphCbgGl ctor`);
super(props);
const radius = 3.5;
if (useSprites) {
this.lowSpriteMaterial = new THREE.MeshBasicMaterial({
map: GraphCbgGl.lowSpriteTexture,
transparent: true,
});
this.normalSpriteMaterial = new THREE.MeshBasicMaterial({
map: GraphCbgGl.normalSpriteTexture,
transparent: true,
});
this.highSpriteMaterial = new THREE.MeshBasicMaterial({
map: GraphCbgGl.highSpriteTexture,
transparent: true,
});
this.spriteGeometry = new THREE.PlaneGeometry(
radius * 2 * this.pixelRatio,
radius * 2 * this.pixelRatio,
1,
1
constructor(props) {
// console.log(`GraphCbgGl ctor`);
super(props);
const radius = 3.5;
if (useSprites) {
this.lowSpriteMaterial = new THREE.MeshBasicMaterial({
map: GraphCbgGl.lowSpriteTexture,
transparent: true,
});
this.normalSpriteMaterial = new THREE.MeshBasicMaterial({
map: GraphCbgGl.normalSpriteTexture,
transparent: true,
});
this.highSpriteMaterial = new THREE.MeshBasicMaterial({
map: GraphCbgGl.highSpriteTexture,
transparent: true,
});
this.spriteGeometry = new THREE.PlaneGeometry(
radius * 2 * this.pixelRatio,
radius * 2 * this.pixelRatio,
1,
1
);
} else {
this.circleGeometry = new THREE.CircleBufferGeometry(
radius * this.pixelRatio,
constructor(props) {
super(props);
// FIXME: It seems that the LineDashedMaterial will clip dashes at the end, rather than hiding
// them, if they don't fit. Ideally we want hide behavior, not clip (similar to the dashed
// UIBezierPath in the old iOS Tidepool Mobile app).
this.suppressedLineMaterial = new THREE.LineDashedMaterial({
color: convertHexColorStringToInt(this.theme.graphBasalLineColor),
linewidth: 2 * this.pixelRatio,
dashSize: 2 * this.pixelRatio,
gapSize: 4 * this.pixelRatio,
});
this.basalRectMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBasalRectColor),
});
}
getMaterial = (texture, transparent) => {
// var texture = new THREE.MeshLambertMaterial(img);
texture.magFilter = THREE.NearestFilter;
texture.minFilter = THREE.NearestFilter;
texture.format = transparent ? THREE.RGBAFormat : THREE.RGBFormat;
texture.needsUpdate = true;
var material = new THREE.MeshBasicMaterial({
map: texture,
transparent: transparent ? true : false,
});
return material;
};
this.highSpriteMaterial = new THREE.MeshBasicMaterial({
map: GraphCbgGl.highSpriteTexture,
transparent: true,
});
this.spriteGeometry = new THREE.PlaneGeometry(
radius * 2 * this.pixelRatio,
radius * 2 * this.pixelRatio,
1,
1
);
} else {
this.circleGeometry = new THREE.CircleBufferGeometry(
radius * this.pixelRatio,
8 * this.pixelRatio
);
this.lowMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgLowColor),
});
this.normalMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgNormalColor),
});
this.highMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgHighColor),
});
}
}
radius * 2 * this.pixelRatio,
1,
1
);
} else {
this.circleGeometry = new THREE.CircleBufferGeometry(
radius * this.pixelRatio,
8 * this.pixelRatio
);
this.lowMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgLowColor),
});
this.normalMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgNormalColor),
});
this.highMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgHighColor),
});
}
}
setupAsync = async () => {
//SKY
this.material = new THREE.MeshBasicMaterial({
map: await ExpoTHREE.loadAsync(Assets.images['sky.png']),
transparent: true,
depthTest: true,
fog: false,
});
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(800, 300, 1, 1),
this.material,
);
mesh.scale.set(20, 20, 20);
mesh.position.z = -3600;
mesh.position.y = 1800;
this.add(mesh);
};
}
transparent: true,
});
this.spriteGeometry = new THREE.PlaneGeometry(
radius * 2 * this.pixelRatio,
radius * 2 * this.pixelRatio,
1,
1
);
} else {
this.lowMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgLowColor),
});
this.normalMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgNormalColor),
});
this.highMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgHighColor),
});
this.circleOutlineGeometry = new THREE.CircleBufferGeometry(
radius * this.pixelRatio,
8 * this.pixelRatio
);
this.circleGeometry = new THREE.CircleBufferGeometry(
(radius - 1) * this.pixelRatio,
8 * this.pixelRatio
);
}
this.backgroundMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBackgroundColor),
});
}
loadAsync = async () => {
const material = new THREE.MeshBasicMaterial({
map: await ExpoTHREE.loadTextureAsync({ asset: Assets.icons['ios.png'] }),
});
const geometry = new THREE.BoxGeometry(1, 1, 1);
for (var i = 0; i < 100; i++) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position
.set(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5)
.normalize();
mesh.position.multiplyScalar(Math.random() * 400);
mesh.rotation.set(
Math.random() * 2,
Math.random() * 2,
Math.random() * 2
);
mesh.scale.multiplyScalar(Math.random() * 50);
});
this.spriteGeometry = new THREE.PlaneGeometry(
radius * 2 * this.pixelRatio,
radius * 2 * this.pixelRatio,
1,
1
);
} else {
this.circleGeometry = new THREE.CircleBufferGeometry(
radius * this.pixelRatio,
8 * this.pixelRatio
);
this.lowMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgLowColor),
});
this.normalMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgNormalColor),
});
this.highMaterial = new THREE.MeshBasicMaterial({
color: convertHexColorStringToInt(this.theme.graphBgHighColor),
});
}
}