[x3d-public] Loading a sub json component

clement at igonet.fr clement at igonet.fr
Mon Mar 21 01:02:20 PDT 2016


John,

   I'm just looking for a way to update an x3d scene using an x3djson external file (or stream). So, the inline approach is convenient.

   Should I update a main and unique x3d json structure, and update my whole scene reloading the x3d json data?

   Could I exploit the inline feature with your x3djdon loader?

   Or maybe you can suggest me something else?

Clement.


Le 21 mars 2016 01:37:51 UTC+01:00, John Carlson <yottzumm at gmail.com> a écrit :
>Try this (untested):
>
>function loadSubscene(selector, url) {
>                $.getJSON(url, function(json) {
>       ConvertToX3DOM(json, "", document.querySelector(selector), url);
>}).fail(function(jqXHR, textStatus, errorThrown) { alert('getJSON
>request failed! ' + textStatus + ' ' + errorThrown); });
>        }
>
>loadSubscene("#mainGroup", "earth.json”);
>
>You may need to do a x3dom.reload(); but I doubt it.
>
>This may become final API, depending on whether I want to handle
>multiple returns from querySelector, and whether I want to introduce a
>dependency on ajax/jquery (I don’t). It will probably appear in a
>utilities library and not be core. I may need it for core to do
>inlines.
>
>
>What do people think about this approach to building a scene? It may
>work, but it seems a bit too imperative.  Obviously, I need to support
>JSON inlines it looks like. I am not sure about synchronous Ajax
>though.  Do inlines require a DEF?
>
>John
>> On Mar 20, 2016, at 7:46 PM, Clement IGONET <clement at igonet.fr>
>wrote:
>> 
>> Hi John.
>> 
>>   I'm trying to load a main scene and then, to add some components...
>> 
>>   The main scene:
>> {
>>    "X3D": {
>>        "@showstat": true,
>>        "@showlog": true,
>>        "@version": "3.0",
>>        "@profile": "Immersive",
>>        "@xmlns:xsd": "http://www.w3.org/2001/XMLSchema-instance",
>>        "@xsd:noNamespaceSchemaLocation":
>> "http://www.web3d.org/specifications/x3d-3.0.xsd",
>>        "Scene": {
>>            "-children": [{
>>                "NavigationInfo": {
>>                    "@type": ["turntable", "fly"],
>>                    "@transitionTime": 5
>>                }
>>            }, {
>>                "Background": {
>>                    "@groundColor": [0.1, 0.1, 0.8],
>>                    "@skyColor": [0.1, 0.1, 0.8]
>>                }
>>            }, {
>>                "GeoViewpoint": {
>>                    "@id": "myGeoViewpoint",
>>                    "@description": "Initial GeoViewpoint",
>>                    "@orientation": [1, 0, 0, -1.57],
>>                    "@position": [35.0, 70.0, 30000000]
>>                }
>>            }, {
>>                "Group": {
>>                    "@id": "mainGroup",
>>                    "@class": "earthPart"
>>                }
>>            }]
>>        }
>>    }
>> }
>> 
>> And the element I'd like to add to Group "mainGroup" a json called
>> "earth.json" containing:
>> [{
>>    "Shape": {
>>        "-appearance": [{
>>            "Appearance": {
>>                "-texture": [{
>>                    "ImageTexture": {
>>                        "@url": "images/earth_big_00.png"
>>                    }
>>                }]
>>            }
>>        }],
>>        "-geometry": {
>>            "GeoElevationGrid": {
>>                "@geoGridOrigin": [0, -180, 0],
>>                "@height": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
>>                "@xDimension": 11,
>>                "@xSpacing": 18,
>>                "@yScale": 200,
>>                "@zDimension": 6,
>>                "@zSpacing": 18
>>            }
>>        }
>>    }
>> }
>> 
>>   So, I tried to load this laste earth.json with this code:
>>    loadX3DJSON(
>>        '#mainGroup',
>>        'earth.json'
>>    );
>> 
>>   Unfortunatly, it does not load anything.
>>   Could you help me ?
>> 
>> Clément.

clement at igonet.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160321/abad1a7f/attachment-0001.html>


More information about the x3d-public mailing list