Published
Edited
Mar 6, 2022
Importers
1 star
Insert cell
Insert cell
gui = new dat.GUI()
Insert cell
Insert cell
gui.domElement.id = 'gui'
Insert cell
styles = html`
<style>
#gui {
position: absolute;
top: 848px;
right: 0px
}

</style>
`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ship = new Vessel.Ship(Gunnerus);
Insert cell
ship3D = new Ship3D(ship, {
shipState: ship.designState.clone(),
stlPath:
"https://shiplab.github.io/vesseljs/examples/3D_models/STL/Gunnerus/",
upperColor: 0x33aa33,
lowerColor: 0xaa3333,
hullOpacity: 0.5,
deckOpacity: 0.5,
objectOpacity: 0.5
})
Insert cell
ship3D.name = "Ship3D"
Insert cell
Insert cell
Insert cell
Insert cell
mutable ModelGLTF = {}
Insert cell
scene.remove(scene.getObjectByName("ModelGLTF"))
Insert cell
Insert cell
scale = gui.addFolder("Visualization parameters")
Insert cell
Insert cell
modelStyle = {
const modelStructure = {
model: "ModelGLTF"
}
return modelStructure
}
Insert cell
Insert cell
scale
.add(modelStyle, "model", {
Model: "ModelGLTF",
Blocks: "Ship3D",
})
.onChange(newValue => {switchElement(newValue)})
.name("View")
Insert cell
scale.open()
Insert cell
function switchElement(stringModel) {
scene.children.forEach(element => {
var otherName = {
ModelGLTF: "Ship3D",
Ship3D: "ModelGLTF"
};

if (element.name == otherName[stringModel]) {
scene.remove(element);
}
});

// Switch function
switch (stringModel) {
case "ModelGLTF":
scene.add(ModelGLTF);
break;

case "Ship3D":
scene.add(ship3D);
break;

default:
break;
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more