[x3d-public] JSON status
Michalis Kamburelis
michalis.kambi at gmail.com
Sun Oct 5 07:09:04 PDT 2025
Indeed Castle Game Engine and Castle Model Viewer support now only
classic and XML encodings, not the JSON encoding, of X3D.
It is possible to add your own model loaders in your own applications,
which John did in https://github.com/coderextreme/jsonmodelviewer/ ,
and add support for X3D JSON encoding this way. Thanks to John, this
is a good starting point.
To "pull it" into CGE master, we'd need to change this code, to load
straight from X3D JSON information (read using FpJson) to Pascal
classes describing X3D nodes (without DOM in the middle, and handling
all X3D fields and nodes in a uniform way, using existing CGE
infrastructure for this -- so that JSON reading is consistent with
classic reading and XML reading). I would welcome PR with it, and I
understand John would eventually like to do this -- thank you in
advance! :)
Note: I'm not sure what you mean by "Note that Castle, in the past,
has had special URLs, indicating a X3dToCastle.xslt or special flags
to add Castlisms." :) We don't have anything X3dToCastle.xslt , and
I'm not sure what special flags you mean. And when you load X3D JSON
in the way I describe above, you will not need to care whether some
X3D aspect is in spec or is CGE extension -- as you will use X3D
fields and nodes names already defined in CGE. The X3D JSON loader
should have no code listing specific nodes and fields, as CGE already
provides this to all loaders.
PR to support JSON encoding would be welcome :)
I would love to see first X3D JSON spec and testcases, but I
understand it's all "work in progress" and for now the best
information we have are linked from:
- https://www.web3d.org/x3d/stylesheets/X3dToJson.html
- https://wiki.web3d.org/wiki/index.php/X3D_JSON_Encoding
- and I understand that the closest thing to spec we have now is:
https://www.web3d.org/specifications/java/references/BrutzmanWalmsleyCarlsonJsonEncodingForX3dJuly2016.pdf
Regards,
Michalis
sob., 4 paź 2025 o 23:46 John Carlson <yottzumm at gmail.com> napisał(a):
>
> Read through some of this as well,
> https://www.web3d.org/x3d/stylesheets/X3dToJson.html
>
> Note that in addition to X3DOM and X_ITE, there is also a prototype JSON .x3dj loader (JSON to DOM to XML) for Castle:
> https://github.com/coderextreme/jsonmodelviewer/
>
> But typically, a Pascal programmer would leverage this on their project, it’s not in the main model viewer yet that I know of. Note that Castle, in the past, has had special URLs, indicating a X3dToCastle.xslt or special flags to add Castlisms. But I think this is unnecessary for the base model viewer.
>
> Further work would involve direct JSON to scenegraph conversion (first attempt failed).
>
> John
>
> On Sat, Oct 4, 2025 at 3:52 PM John Carlson <yottzumm at gmail.com> wrote:
>>
>>
>>
>> On Sat, Oct 4, 2025 at 3:22 PM Don Brutzman via x3d-public <x3d-public at web3d.org>If progress continues as planned, we should be able to have a draft XML DTD/Schema (and hopefully JSON Schema too) in the spring in order to start building, validating, and evaluating models with such new features.
>>
>> Don:
>>
>> Any time you want help with validating JSON documents, let me know. I can always rev-up my x3droundtrip project as well!
>>
>> I also note that jsonlint provides schema validation that I apparently missed!
>>
>> Here’s a version which supports
>> draft JSON Schema 2020-12:
>>
>> https://www.npmjs.com/package/@prantlf/jsonlint
>>
>> If you can work with uncertainties in npm (check package.json and package-lock.json dependencies and pinned versions, make sure you’re not running postinstall scripts). Note that npm already checks for vulnerabilities. And if you have GitHub, it also checks for issues in the package*.json files.
>>
>> I have not seen these features in ant, maven or gradle, but I have seen that maven repositories do report vulnerabilities.
>>
>> One issue I haven’t resolved is choosing emoji’s versus X3D URNs in url fields. It’s a matter of iri-reference verses uri-reference in the format properties in the schema.
>>
>> Note that I think you’ll probably find many issues with MFNode vs SFNode in X3dToJson.xslt which I haven’t reported. Most of my XML to JSON conversions have migrated to Holger’s x3d-tidy.
>>
>> John
>>
More information about the x3d-public
mailing list