Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "solid with marker color" view mode from #2316 #2331

Merged
merged 3 commits into from
May 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix custom Marker Colors breaking and freezing the canvas
Azagwen committed May 12, 2024
commit a565e7209f2d260fa445dde36ae8daa8701e9ff0
39 changes: 19 additions & 20 deletions js/preview/canvas.js
Original file line number Diff line number Diff line change
@@ -130,22 +130,6 @@ const Canvas = {
wireframeMaterial: new THREE.MeshBasicMaterial({
wireframe: true
}),
coloredSolidMaterials:[],
createColoredSolidMaterials() {
markerColors.forEach(function(color, i) {
if (Canvas.coloredSolidMaterials[i]) return;
Canvas.coloredSolidMaterials[i] = new THREE.ShaderMaterial({
uniforms: {
SHADE: {type: 'bool', value: settings.shading.value},
BRIGHTNESS: {type: 'bool', value: settings.brightness.value / 50},
base: {value: new THREE.Color().set(color.pastel)}
},
vertexShader: SolidMaterialShaders.vertShader,
fragmentShader: SolidMaterialShaders.fragShader,
side: THREE.DoubleSide
});
})
},
monochromaticSolidMaterial: (function() {
return new THREE.ShaderMaterial({
uniforms: {
@@ -336,6 +320,7 @@ const Canvas = {
})
})(),
emptyMaterials: [],
coloredSolidMaterials:[],
updateMarkerColorMaterials() {
var img = new Image()
img.src = 'assets/missing.png'
@@ -419,17 +404,32 @@ const Canvas = {

markerColors.forEach(function(color, i) {
if (Canvas.emptyMaterials[i]) return;

// Define uniforms that all marker colored shaders share
let commonUniforms = {
SHADE: {type: 'bool', value: settings.shading.value},
BRIGHTNESS: {type: 'bool', value: settings.brightness.value / 50},
base: {value: new THREE.Color().set(color.pastel)}
}

// Empty texture materials
Canvas.emptyMaterials[i] = new THREE.ShaderMaterial({
uniforms: {
map: {type: 't', value: tex},
SHADE: {type: 'bool', value: settings.shading.value},
BRIGHTNESS: {type: 'bool', value: settings.brightness.value / 50},
base: {value: new THREE.Color().set(color.pastel)}
...commonUniforms
},
vertexShader: vertShader,
fragmentShader: fragShader,
side: THREE.DoubleSide,
})

// Colored solid materials
Canvas.coloredSolidMaterials[i] = new THREE.ShaderMaterial({
uniforms: commonUniforms,
vertexShader: SolidMaterialShaders.vertShader,
fragmentShader: SolidMaterialShaders.fragShader,
side: THREE.DoubleSide
});
})
},
transparentMaterial: new THREE.MeshBasicMaterial({visible: false, name: 'invisible'}),
@@ -612,7 +612,6 @@ const Canvas = {

setup() {
Canvas.updateMarkerColorMaterials();
Canvas.createColoredSolidMaterials();

//Light
Sun = new THREE.AmbientLight( 0xffffff );