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

Elements web assembly API #874

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3e9c08e
Set up for separate run.
ikeough Aug 1, 2022
8253269
A little more cleanup.
ikeough Aug 1, 2022
3a1910e
Rudimentary inputs working.
ikeough Aug 1, 2022
5ec7123
Styling tweaks.
ikeough Aug 1, 2022
b5285cf
Merge branch 'buffer-perf' into playground
ikeough Aug 1, 2022
63583dc
Cleanup.
ikeough Aug 1, 2022
85c654f
Run at start.
ikeough Aug 1, 2022
1db3e98
Shadows and visual tweaks.
ikeough Aug 1, 2022
01be8da
Typed inputs working.
ikeough Aug 2, 2022
e030fa8
Color inputs working.
ikeough Aug 2, 2022
cb9b026
Point inputs working.
ikeough Aug 2, 2022
243a9b7
Profile inputs working.
ikeough Aug 2, 2022
6f51451
Fix null ref exception on profle.
ikeough Aug 2, 2022
edccc7f
Editable profile names.
ikeough Aug 2, 2022
2e794fa
Scroll the inputs field.
ikeough Aug 2, 2022
44ef01a
Use HDR lighting.
ikeough Aug 2, 2022
7e6546b
Cleaning up the model.
ikeough Aug 2, 2022
dd9fc88
Move inputs to middle.
ikeough Aug 2, 2022
fdd0751
Style tweaks
ikeough Aug 2, 2022
d12d372
Get Ace editor from another CDN.
ikeough Aug 3, 2022
26d1edc
Transformable point working.
ikeough Aug 3, 2022
3128411
Update state when moving point.
ikeough Aug 3, 2022
c29bfc6
Fix binding syntax to avoid lag.
ikeough Aug 4, 2022
b1e43c9
Save the code between page loads.
ikeough Aug 4, 2022
4514660
Don't save the code.
ikeough Aug 4, 2022
ab558cb
Only set on construction.
ikeough Aug 4, 2022
89c5df5
Support multiple vector inputs.
ikeough Aug 4, 2022
821d13f
More static inputs.
ikeough Aug 4, 2022
7a6cf5c
Merge branch 'master' into playground
ikeough Aug 6, 2022
8b4125e
In memory images for textures.
ikeough Aug 7, 2022
b5c89ea
Merge branch 'master' into playground
ikeough Aug 22, 2022
b2dbf4c
Merge branch 'master' into playground
ikeough Aug 23, 2022
29324ac
Revert "In memory images for textures."
ikeough Aug 23, 2022
7c69270
Merge branch 'playground' into wasm
ikeough Aug 23, 2022
6e6b925
Fold elements.wasm into playground.
ikeough Aug 26, 2022
5409d45
Better documentation.
ikeough Aug 26, 2022
a7b41fd
Add some auto-generated VS stuff.
ikeough Aug 27, 2022
3960c99
A tiny demo app with documentation.
ikeough Aug 27, 2022
b9b2811
fixes for explore-based playground
andrewheumann Aug 29, 2022
7c2a0fe
add serve script
andrewheumann Aug 29, 2022
02ebfce
PR comments
andrewheumann Aug 29, 2022
1a4e7e1
Merge branch 'master' into wasm
ikeough Sep 1, 2022
e74a89c
Merge pull request #875 from hypar-io/wasm-explore-fixes
andrewheumann Sep 1, 2022
c850fff
Merge remote-tracking branch 'origin/master' into wasm
andrewheumann Oct 30, 2022
2d9e54f
add spatial to default imports
andrewheumann Oct 30, 2022
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
Next Next commit
Shadows and visual tweaks.
ikeough committed Aug 1, 2022
commit 1db3e9810ea22e9aa0bf6b0936ac0622353490ff
64 changes: 53 additions & 11 deletions Elements.Playground/wwwroot/js/model.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@ window.model = {
const scene = new THREE.Scene();
var gltfScene = null;
var editor = null;
var directionalLight = null;
var renderer = null;

function loadModel(glb) {
const contentArray = Blazor.platform.toUint8Array(glb);
@@ -27,6 +29,13 @@ function loadModel(glb) {
scene.remove(gltfScene);
}

gltf.scene.traverse((o) => {
if (o instanceof THREE.Mesh) {
o.castShadow = true;
o.receiveShadow = true;
}
})

scene.add(gltf.scene);
gltfScene = gltf.scene;

@@ -66,26 +75,59 @@ function initializeEditor() {

function initialize3D() {
const div = document.getElementById("model");
const camera = new THREE.PerspectiveCamera(75, div.clientWidth / div.clientHeight, 0.1, 1000);
const camera = new THREE.PerspectiveCamera(75, div.clientWidth / div.clientHeight, 0.1, 300);

const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap
renderer.physicallyCorrectLights = true;
renderer.outputEncoding = THREE.sRGBEncoding
renderer.toneMappingExposure = 0.9

renderer.setSize(div.clientWidth, div.clientHeight);
div.appendChild(renderer.domElement);

const controls = new OrbitControls(camera, renderer.domElement);

const directionalLight = new THREE.DirectionalLight(0xffffff, 1.0);
directionalLight.position.set(0.5, 0.5, 0);
directionalLight = new THREE.DirectionalLight(0xffffff, 0.8 * Math.PI);
directionalLight.position.set(-2, 10, 0);
directionalLight.castShadow = true; // default false
// directionalLight.shadow.radius = 12
scene.add(directionalLight);

const size = 100;
const divisions = 20;

const gridHelper = new THREE.GridHelper(size, divisions, "darkgray", "lightgray");
scene.add(gridHelper);

const light = new THREE.HemisphereLight(0xffffbb, 0x080820, 1.0);
var side = 30
directionalLight.shadow.mapSize.width = 4096;
directionalLight.shadow.mapSize.height = 4096;
// directionalLight.shadow.camera.near = 1;
// directionalLight.shadow.camera.far = 20;
directionalLight.shadow.camera.left = -side
directionalLight.shadow.camera.right = side
directionalLight.shadow.camera.top = side
directionalLight.shadow.camera.bottom = -side
directionalLight.shadow.bias = -0.00001 // -r / 2000000.0

// const size = 100;
// const divisions = 20;

// const gridHelper = new THREE.GridHelper(size, divisions, "darkgray", "lightgray");
// scene.add(gridHelper);

// const helper = new THREE.CameraHelper(directionalLight.shadow.camera);
// scene.add(helper);

// Create a shadow plane
var shadowMaterial = new THREE.ShadowMaterial();
shadowMaterial.opacity = 0.5;
const planeGeometry = new THREE.PlaneGeometry(50, 50, 32, 32);
const plane = new THREE.Mesh(planeGeometry, shadowMaterial);
plane.rotateX(-Math.PI / 2);
plane.receiveShadow = true;
scene.add(plane);

const axesHelper = new THREE.AxesHelper(5);
scene.add(axesHelper);

const light = new THREE.AmbientLight(0x404040); // soft white light
scene.add(light);

camera.position.z = 5;