googlevr / poly-sample-web Goto Github PK
View Code? Open in Web Editor NEWWeb sample for Poly API
License: Apache License 2.0
Web sample for Poly API
License: Apache License 2.0
Hello Google Team,
We experience issues with the Web samples of Poly API : Today, the search sample is not working anymore because of this issue :
7:1 Failed to load https://poly.googleapis.com/downloads/6XXj6DSBb08/dH3skx1SVUc/materials.mtl: Redirect from 'https://poly.googleapis.com/downloads/6XXj6DSBb08/dH3skx1SVUc/materials.mtl' to 'https://vrassets-pa.googleusercontent.com/downloads/6XXj6DSBb08/dH3skx1SVUc/materials.mtl' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost/workspace' is therefore not allowed access.
We have currently hot fixed the problem by replacing the request URL of the MTL/OBJ Loader in the script.
Regards
search-sample appears to need a "position:absolute" in the css for the #viewer span. Otherwise the display viewport height is truncated to 0 in chrome.
When loading an OBJ format object with textures, the texture loads fail as they attempt to load from server, rather than the resources actual remote directory specified by its url.
A workaround/hack is to insert the following code in the loading code in search-sample->createImage, where the MTLLoader is created:
var loader = new THREE.MTLLoader();
loader.setCrossOrigin(true);
for(var i=0;i<format.resources.length;i++){
var resource = format.resources[i];
if(resource.contentType.indexOf("image/")==0){
var texPathEnd = resource.url.indexOf(resource.relativePath);
if(texPathEnd!=-1){
loader.setTexturePath(resource.url.slice(0,texPathEnd));
break;
}
}
}
This hack finds the first image/* resource, subtracts the filename from the URL, then sets the MTLLoaders "texturePath" to that. MTLLoader uses this path in subsequent texture load attempts.
Note, this triggers cross origin request, which requires setting loader.setCrossOrigin(true);
-hth
For instance, the "tasmanian wolf" (only occurrence when searching TASMANIAN)
assets/2yEZA3TLwVI
This is due to "lighting" being set on the LineBasicMaterial for wireframe objects.
This can be fixed by adding the following code inside "createImage" after:
loader.load( urlOBJ, function ( object ) {
object.traverse((node)=>{
var materials = [];
if(node.material instanceof Array){
for(var i=0;i<node.material.length;i++){
if(node.material[i].type == "LineBasicMaterial"){
node.material[i].lights = false;
}
}
}else{
if(node.material){
if(node.material.type == "LineBasicMaterial"){
node.material.lights = false;
}
}
}
})
This is more of a question to be honest. Would it be possible to keep the effects applied by poly.google on the model we import when using the API? If it is not possible to have them imported by Poly could you just give some clues on how to obtain the visual effect as Poly ? If it is not too much to ask ^^
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.