Comments (10)
Prototype can only be created using declarative syntax, they are not made to be created per scripting. You would create a function which returns one or more nodes, which is almost what a prototype does.
from x_ite.
Okay, what about InstancedShape ? I would like to display thousands of spheres and cylinders in the scene with a specific transform for each. For now, I am creating thousands of shapes making the browser slow to load and decreasing the framerate.
What if I use fromXmlString to load a node ?
I could also create the geometry for one sphere myself and duplicate and merge them into a large TriangleSet.
I'll be trying these solutions today, will report back on what works. If you have other ideas about what might work, please let me know.
from x_ite.
InstancedShape is made for this task. Of course you can use Browser.createX3DFromString to load a data with a protoype.
const scene = await browser .createX3DFromString (`PROTO Foo [
# fields come here
]
{
# Body comes here
}`);
// Now create an instance:
const instance = scene .createProto ("Foo");
from x_ite.
Okay, I have tried the InstancedShape in a simple X3D scene. No JS is involved.
I noticed that you need to add a header with a X_ITE component before the Scene tag like so:
<head>
<component name='X_ITE' level='1'/>
</head>
Otherwise I get the following error in the Chrome browser and the Shape does not display
XML Parser: Unknown node type 'InstancedShape', you probably have insufficient component/profile statements and/or an inappropriate specification version.
I am just putting this here in case it helps other people.
I guess the InstancedShape is not standard X3D and I missed the place in the doc where this component stuff was indicated.
from x_ite.
Found it in the InstancedShape description ...
Just need to find how to tell the browser to use this component with JS now.
from x_ite.
This works for modifying the header
const comp = xBrowser.getComponent ("X_ITE", 1);
scene.addComponent(comp);
But I still get Unknown node type 'InstancedShape'
when creating the node const instShape = scene.createNode("InstancedShape");
from x_ite.
const scene = await browser .createX3DFromString (`
COMPONENT X_ITE : 1
PROTO Foo [
# fields come here
]
{
# Body comes here
}`);
// Now create an instance:
const instance = scene .createProto ("Foo");
Add a component statement like the above.
from x_ite.
If you do it in the parser, you must first load the components:
scene .addComponent (browser .getComponent (componentName));
this .loadComponents () .then (() =>
{
this .resolve (scene);
})
.catch (this .reject);
Where loadComponents
is defined in X3DParser.
from x_ite.
Thank you very much, that did the trick !
Is there a way to change the color of each instance ? Defining a color array in the material perhaps ? or having a colors
property in the instancedShape like the rotations
would be pretty neat.
from x_ite.
No this is not possible. If you have only a few colors, you could create a InstancedShape node for every color, otherwise you can create one big geometry with all faces and colors.
from x_ite.
Related Issues (20)
- Issue with model in X3D archives HOT 2
- Can't use x_ite from inside a Firefox extension; can ResizeSensor.js be pruned? HOT 9
- Scientific data visualization HOT 6
- Weird shader effects, missing images, possibly due to reconfiguring Firewall, hostname, DNS servers HOT 1
- Custom elements issue with x_ite.mjs in Microsoft Edge? HOT 3
- npx sunrize [files] HOT 5
- X_ITE React implementation questions HOT 5
- "aspectRatio" not supported? HOT 4
- Despite no errors on the console, X_ITE shows no graphics HOT 10
- Use RENDERER on Firefox HOT 1
- ExternProtoDeclare not downloading? X3D checks in X3D-Edit. HOT 3
- Mono Sound plays only over left speaker HOT 3
- How to start X_ITE in a browser window in fullscreen mode HOT 3
- "Better" webpack.config.js, for Git Bash under Windows 10 HOT 5
- Replace webpack "string-replace-webpack-plugin" or provide dependency overrides in package.json HOT 2
- Adding a new node HOT 13
- Filling up an empty scene with Javascript HOT 8
- IndexedFaceSet solid false and alpha HOT 1
- EnvironmentLight has no effect (noob question number 3) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from x_ite.