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

Improve transparency rendering of model #723

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 13 additions & 2 deletions src/plugins/nodeVisualizer/modelVisualization.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,23 @@ class ModelVisualization
getSolid: =>
@threeNode.solid

getSolidLines: =>
@threeNode.solidLines

_createVisualization: (node) =>

_addSolid = (geometry, parent) =>
solid = new THREE.Mesh geometry, @coloring.objectPrintMaterial
parent.add solid
parent.solid = solid

# visible black lines, again!
lineObject = new THREE.Mesh geometry
lines = new THREE.EdgesHelper lineObject, 0x000000, 30
lines.material = @coloring.objectLineMatFront
parent.add lines
parent.solidLines = lines

_addWireframe = (geometry, parent) =>
wireframe = new THREE.Object3D()

Expand All @@ -57,11 +67,12 @@ class ModelVisualization
.then (modelObject) =>
geometry = threeConverter.toStandardGeometry modelObject

if @globalConfig.rendering.showModel
_addSolid geometry, @threeNode
if @globalConfig.rendering.showShadowAndWireframe
_addWireframe geometry, @threeNode

if @globalConfig.rendering.showModel
_addSolid geometry, @threeNode

threeHelper.applyNodeTransforms node, @threeNode

@afterCreationPromise = node.getModel().then _addModel
Expand Down
15 changes: 12 additions & 3 deletions src/plugins/nodeVisualizer/nodeVisualizer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class NodeVisualizer
constructor: ->
# rendering properties
@brickVisualizations = {}
@modelVisualizations = {}
@fidelity = 0

init: (@bundle) =>
Expand Down Expand Up @@ -212,6 +213,11 @@ class NodeVisualizer
for nodeId, brickVisualization of @brickVisualizations
brickVisualization.setFidelity @fidelity

# Turn off second wireframe pass when pipeline is rendered
for nodeId, modelVisualization of @modelVisualizations
lines = modelVisualization.getSolidLines()
lines.visible = not @usePipeline

# called by newBrickator when an object's data structure is modified
objectModified: (node, newBrickatorData) =>
@_getCachedData(node)
Expand Down Expand Up @@ -292,16 +298,19 @@ class NodeVisualizer
)
@brickVisualizations[node.id] = brickVisualization

modelVisualization = new ModelVisualization(
@bundle.globalConfig, node, modelThreeNode, @coloring
)
@modelVisualizations[node.id] = modelVisualization

data = {
initialized: false
node: node
brickThreeNode: brickThreeNode
brickShadowThreeNode: brickShadowThreeNode
modelThreeNode: modelThreeNode
brickVisualization: brickVisualization
modelVisualization: new ModelVisualization(
@bundle.globalConfig, node, modelThreeNode, @coloring
)
modelVisualization: modelVisualization
}

return data
Expand Down
11 changes: 8 additions & 3 deletions src/plugins/nodeVisualizer/visualization/Coloring.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,21 @@ module.exports = class Coloring
opacity: 0.4
depthFunc: THREE.GreaterDepth
)
@objectShadowMat.depthWrite = false

@_setPolygonOffset @objectShadowMat, +3, +3

lineMaterialGenerator = new LineMatGenerator()
@objectLineMat = lineMaterialGenerator.generate 0x000000
@objectLineMat.linewidth = 2
@objectLineMat.transparent = true
@objectLineMat.opacity = 0.1
@objectLineMat.depthFunc = THREE.GreaterDepth
@objectLineMat.depthFunc = THREE.AlwaysDepth
@objectLineMat.depthWrite = false

@objectLineMatFront = lineMaterialGenerator.generate 0x000000
@objectLineMatFront.linewidth = 2
@objectLineMatFront.depthFunc = THREE.LessEqualDepth
@objectLineMatFront.depthWrite = true

@_createBrickMaterials()

_setPolygonOffset: (material, polygonOffsetFactor, polygonOffsetUnits) ->
Expand Down