xml3d / xml3d.js

The WebGL/JS implementation of XML3D
Other
75 stars 25 forks source link

simple spotlight + shadow example #166

Closed telethonic closed 8 years ago

telethonic commented 8 years ago

Hello,

I've been looking all over for this, to no avail :-(

I've tried to whittle down this example: http://xml3d.github.io/xml3d-examples/examples/spotLight/index.html to one that just has the surface, the cube, the spotlight and its light + the cube's shadow.

I thought I could just remove the LampShade geometry from the scene, for example, but apparently not.

Does anyone have a basic spotlight + shadow example?

Also, the "as defined here" link on that page goes to an empty wiki page. And the 5.0 spec for spot lights is missing falloffAngle (= cutoffAngle?), castShadow, and shadowBias, is there a later spec that includes these?

Many thanks :)

ksons commented 8 years ago

Hi @telethonic!

Yes, falloffAngle has been renamed to cutoffAngle. I just fixed that in xml3d/xml3d-examples@08edff4b753ba5bcb20b10c411e8da673f4d0d3a.

I couldn't reproduce your issue with the shadows. If I open the console for: http://xml3d.github.io/xml3d-examples/examples/spotLight/index.html

and remove the Lamp including cables:

$("#Lamp,#group1").remove();

it results in a very basic spotlight + shadow example for me (tested this in Chrome and Firefox).

If it does not work for you, can you please give details on which system you are running and if there any errors in the console.

Thanks!

telethonic commented 8 years ago

Thanks for the quick response :-)

In my test I had downloaded the shadow example HTML file, and all dependent files (so the .js files, .css, etc.).

I then removed the LampShape geometry (so the bit between

<data id="LampShape"> ...
</data>

and the Lamp group.

Edit: doing these removals again, and now it works :-/

So fine to close this issue, thanks for your help

ksons commented 8 years ago

Hi,

the LampShape <data> element defines the data for a latter mesh (in more recent examples, the geometry data is defined in external resources which results in faster loading times and better handling of the HTML file). So if you remove this data, the <mesh> element points to an empty data block:

Since the mesh requires at least positions, you should see following error in the console:

Mesh Error: Mesh does not have 'position' attribute. 

So you should at least remove the mesh as well.

However, even with these errors I get a correct shadow. Could you please try it the way I sketched above? If it works, I would close the issue.

telethonic commented 8 years ago

See my edit above, fine to close, thanks.