Public
Edited
Sep 10, 2019
1 star
Insert cell
Insert cell
objectTemplate = new Vessel.BaseObject();
Insert cell
Insert cell
objectTemplate.id = "First Object";
Insert cell
objectTemplate.boxDimensions = {
"length": 10,
"breadth": 4,
"height": 2
};
Insert cell
Insert cell
myObject = new Vessel.DerivedObject();
Insert cell
myObject.id = "Tank1";
Insert cell
Insert cell
myObject.baseObject = objectTemplate;
Insert cell
myObject.affiliations = {};
Insert cell
myObject.referenceState = {
"xCentre": 10,
"yCentre": 0,
"zBase": 0
};
Insert cell
Insert cell
emptySpec = ({
"designState": {
"calculationParameters": {
"Draft_design": 2
}
},
"structure": {
"hull": {
"attributes": {
"LOA": 20
},
"halfBreadths": {
"waterlines": [],
"stations": [],
"table": []
}
},
"decks": {},
"bulkheads": {}
},
"baseObjects": [],
"derivedObjects": []
});
Insert cell
Insert cell
ship = new Vessel.Ship(emptySpec);
Insert cell
ship.baseObjects[objectTemplate.id] = objectTemplate;
Insert cell
ship.derivedObjects[myObject.id] = myObject;
Insert cell
Insert cell
ship3D = new Ship3D(ship);
Insert cell
Insert cell
{
const renderer = new THREE.WebGLRenderer({antialias: true});
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xA9CCE3);
const height = 600;
const aspect = width / height;
const camera = new THREE.PerspectiveCamera(30);
camera.up.set(0, 0, 1);
scene.add(camera);
const LOA = ship.structure.hull.attributes.LOA;
camera.position.set(0.7 * LOA, 0.7 * LOA, 0.7 * LOA);
function onWindowResize() {
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener('resize', onWindowResize);
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.target = new THREE.Vector3(LOA / 2, 0, 0);
controls.update();
invalidation.then(() => renderer.dispose());
renderer.setSize(width, height);
renderer.setPixelRatio(devicePixelRatio);
scene.add(ship3D);
const ambientLight = new THREE.AmbientLight(0xffffff, 0.3);
const mainLight = new THREE.DirectionalLight(0xffffff, 1);
mainLight.position.set(1, 1, 1);
scene.add(ambientLight, mainLight);
var animate = function () {
requestAnimationFrame( animate );
renderer.render( scene, camera );
};
animate();
yield renderer.domElement;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more