How to migrate from THREE.SceneLoader? r84 - three.js

Currently at the tail end of a migration from r69 to r84 and I'm wondering what the best way would be to migrate from THREE.SceneLoader to either THREE.JSONLoader or THREE.ObjectLoader.
When I attempt to use the JSONLoader I get an error that I should use the SceneLoader instead, kind of strange considering it's been deprecated.
Looking at the source of JSONLoader I guess if the type of data coming in is scene then it will throw this error, but what should the type be and is JSONLoader even the right replacement?

Related

Loading protocol buffer in ruby or java similar to node

I have a .proto file that contains my schema and service definition. I'm looking for a method in ruby/java that is similar to how Node loads and parses it (code below). Looking at the grpc ruby gem, I don't see anything that can replicate how Node does it.
Digging around I see this (https://github.com/grpc/grpc/issues/6708) which states that dynamically loading .proto files is only available in node. Hopefully, someone can provide me with an alternative.
Use case: Loading .proto files dynamically as provided in the client but I can only use either ruby or java to do it.
let grpc = require("grpc");
let loader = require("#grpc/proto-loader");
let packageDefinition = loader.loadSync(file.file, {});
let parsed = grpc.loadPackageDefinition(packageDefinition);
I've been giving this a try for the past few month and it seems like Node is the only way to read a protobuf file on runtime. Hopefully this helps anyone in the future that needs it.

Use Geography PostGIS function with H2GIS

I have this function where I get a hibernate spatial Geometry type and buffer it in meters like so
entityManager
.createNativeQuery(“SELECT ST_BUFFER(GEOGRAPHY(:geometry), :margin, ‘join=mitre’) AS BUFFERED_GEOMETRY”)
.setParameter(“geometry”, geometry)
.setParameter(“margin”, margin)
.unwrap(NativeQuery.class)
.addScalar(“ BUFFERED_GEOMETRY”, new JTSGeometryType(PGGeometryTypeDescriptor.INSTANCE))
.getSingleResult();
This code works perfectly when I use postGIS but when I use h2GIS in my tests I get a sql error
Function “GEOGRAPHY” not found
I indeed saw that this function and some others don’t exist in the H2GISFunctions.class. Is there a way around this? Except using Postgres in my tests?
I don't know H2GIS, but PostgreSQL is almost as fast as H2 if you avoid most DDL and use TRUNCATE for clearing data between tests, so why wouldn't you want to test against the database that you also use in production?

Joomla 3.0 generic database error handling

Going from Joomla 2.5 to 3.0 with my extension, I'm struggling with how to do the DB error handling (since GetErrorNum is deprecated, see also Joomla! JDatabase::getErrorNum() is deprecated, use exception handling instead).
The way that seems to be the one to go according to the question linked above, is to add the following code for each db->query() code:
if (!$db->query()) {
throw new Exception($db->getErrorMsg());
}
In my opinion, that makes DB error handling more awkward than it was before. So far, I simply called a checkDBError() function after a DB call, which queried the ErrorNum and handled any possible error accordingly.
That was independent from how the DB query was actually triggered - there are different ways to do that, and different results on an error: $db->loadResult() returns null on error, $db->query() returns false. So there will now be different checks for different DB access types.
Isn't there any generic way to handle this, e.g. a way to tell Joomla to throw some exception on DB problems? Or do I have to write my own wrapper around the DatabaseDriver to achieve that? Or am I maybe missing something obvious?
Or should I just ignore the deprecation warning for now and continue with using getErrorNum()? I'd like to make my extension future-proof, but I also don't want to clutter it too much with awkward error handling logic.
Just found this discussion: https://groups.google.com/forum/#!msg/joomla-dev-general/O-Hp0L6UGcM/XuWLqu2vhzcJ
As I interpret it, there is that deprecation warning, but there is no proper replacement yet anyway...
Unless somebody points out any other proper documentation of how to do it in 3.0, I will keep to the getErrorNum method of doing stuff...
Get getErrorNum() function will solve your problem....
$result = $db->loadResult();
// Check for a database error.
if ($db->getErrorNum())
{
JFactory::getApplication()->enqueueMessage($db->getErrorMsg());
return false;
}

THREE.EffectComposer.scene.addObject( THREE.EffectComposer.quad ); has no method 'addObject'

First, before I ask you some newbie questions, I would like thanks MrDoob & co for all this good work, I'm really pleased to use three.js.
But actually, I'm trying to use some shaders and post effects to render a beautiful sun in my solar system. For that I inspired myself a lot from your lava taurus example.
When I adapt it in my code, I got the following JS error :
Uncaught TypeError: Object [object Object] has no method 'addObject' EffectComposer.js:129
THREE.WebGLRenderer 49 Three.js:331
Uncaught TypeError: undefined is not a function BloomPass.js:27
The first seems to be an classic js error but I cannot find the reason, the code seems good :
THREE.EffectComposer.scene = new THREE.Scene();
THREE.EffectComposer.scene.addObject( THREE.EffectComposer.quad );
And the second points to :
this.materialScreen = new THREE.MeshShaderMaterial( {
Finally, I tried with your sample code without modifying it (I just deleted the stats part in the code) and didn't include these two files (cause I didn't find the source) :
<script src="js/Detector.js"></script>
<script src="js/Stats.js"></script>
And I get the same first error related to the effectComposer.
Thanks a lot,
I found the solution. First I hadn't the right include files (mine were older). Then; I didn't structure my code well and missed couple of things.
Now it is fixed, and I don't know actually who did the lava taurus in your examples Mr.Doob but the shaders are simply stunning.
If you wanna take a look to my solarsystem : http://www.scgaming.eu/
I work it out, but I'm thinking about how optimise it and how writing the code better than it h

how to serialize an object using TCPServer inside?

In an effort to speed up frequently repeated runs of a particular script in my chain, I started serializing to disk custom objects that otherwise take too much time to create aggregately.
Using built-in Yaml and/or Marshal.
Yaml serializes fine to a seemingly healthy text file but produces the following error when trying to deserialize:
b2 = YAML::load(File.open("browserObj.yaml", 'r'))
Syck::TypeError: Invalid Regular expression: "/\\A\\s*\n ([a-zA-Z][-+.a-zA-Z\\d]*): ...and many more strange lines
However even trying to save to a binary file via Marshal errors:
puts File.open("browserObj.bin", 'w').write Marshal::dump($browser)
TypeError: can't dump TCPServer
# Marshal::dump($browser, File.open("browserObj.bin", 'wb')) # same error
By deliberately not doing $browser.close at the end I have the option to keep this TCPServer alive and running after the lifetime of my Ruby script.
Any thoughts on how I can get away with this? I promise upon successful reloading to double-check the validity of any sockets/inner objects and simply re-initialize a whole new object if I have to.

Resources