Camera インスタンスの near プロパティ(近接平面距離)と far プロパティ(遠方平面距離)に設定する値には注意が必要です。
これらの値は Maprayエンジン が内部で使用している WebGL で必要になるパラメータです。
これらの値をコンテンツ開発者が指定しなければならない理由は、そのコンテンツにとって適切な値を Maprayエンジン が決定することが困難だからです。
<!DOCTYPE html><html><head><metacharset="UTF-8"><scriptsrc="./v0.10.0/mapray.min.js"></script><linkrel="stylesheet"href="./mapray.css"><style>html,body,div#mapray-container{margin:0;padding:0;height:100%;}</style></head><body><divid="mapray-container"></div></body></html><script>classMyRenderCallbackextendsmapray.RenderCallback{constructor(){super();this.longitude=138.730647;this.latitude=35.362773;this.height=3776.24;this.distance=10000.0;this.pitch_angle=-30.0;this.angular_velocity=5.0;this.turn_angle=0;}onStart()// override{// Initial turn anglethis.turn_angle=0;}onUpdateFrame(delta_time)// override{constcamera=this.viewer.camera;// Set transformation matrix to cameramapray.GeoMath.mul_AA(this.createBaseToGocsMatrix(),this.createViewToBaseMatrix(),camera.view_to_gocs);// Set near-far plane to cameracamera.near=this.distance/2;camera.far=camera.near*1000;// next turn anglethis.turn_angle+=this.angular_velocity*delta_time;}// Generate transformation matrix from reference coordinate system to GOCScreateBaseToGocsMatrix(){constbase_to_gocs=mapray.GeoMath.createMatrix();mapray.GeoMath.iscs_to_gocs_matrix({longitude:this.longitude,latitude:this.latitude,height:this.height},base_to_gocs);returnbase_to_gocs;}// Generate a transformation matrix from the viewpoint coordinate system to the reference coordinate systemcreateViewToBaseMatrix(){constt=this.turn_angle*mapray.GeoMath.DEGREE;// turn angle (radian)constp=this.pitch_angle*mapray.GeoMath.DEGREE;// elevation/depression angle (radian)constd=this.distance;constsinT=Math.sin(t);constcosT=Math.cos(t);constsinP=Math.sin(p);constcosP=Math.cos(p);constmat=mapray.GeoMath.createMatrix();mat[0]=cosT;mat[1]=sinT;mat[2]=0;mat[3]=0;mat[4]=sinP*sinT;mat[5]=-sinP*cosT;mat[6]=cosP;mat[7]=0;mat[8]=sinT*cosP;mat[9]=-cosT*cosP;mat[10]=-sinP;mat[11]=0;mat[12]=d*sinT*cosP;mat[13]=-d*cosT*cosP;mat[14]=-d*sinP;mat[15]=1;returnmat;}}// Set up your access token, which can be created in Mapray Cloud.constcloudApi=newmapray.cloud.CloudApiV2({tokenType:mapray.cloud.CloudApi.TokenType.API_KEY,token:"<YOUR_MAPRAY_API_KEY>"});constviewer=newmapray.Viewer("mapray-container",{render_callback:newMyRenderCallback(),image_provider:newmapray.StandardImageProvider({url:"https://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/",format:"jpg",min_level:2,max_level:18,}),dem_provider:newmapray.StandardDemProvider(cloudApi.getDefaultDemAsResource())});</script>
<!DOCTYPE html><html><head><metacharset="UTF-8"><scriptsrc="https://resource.mapray.com/mapray-js/v0.9.6/mapray.min.js"></script><linkrel="stylesheet"href="https://resource.mapray.com/styles/v1/mapray.css"><style>html,body,div#mapray-container{margin:0;padding:0;height:100%;}</style></head><body><divid="mapray-container"></div></body></html><script>classMyRenderCallbackextendsmapray.RenderCallback{constructor(){super();this.longitude=138.730647;this.latitude=35.362773;this.height=3776.24;this.distance=10000.0;this.pitch_angle=-30.0;this.angular_velocity=5.0;this.turn_angle=0;}onStart()// override{// Initial turn anglethis.turn_angle=0;}onUpdateFrame(delta_time)// override{constcamera=this.viewer.camera;// Set transformation matrix to cameramapray.GeoMath.mul_AA(this.createBaseToGocsMatrix(),this.createViewToBaseMatrix(),camera.view_to_gocs);// Set near-far plane to cameracamera.near=this.distance/2;camera.far=camera.near*1000;// next turn anglethis.turn_angle+=this.angular_velocity*delta_time;}// Generate transformation matrix from reference coordinate system to GOCScreateBaseToGocsMatrix(){constbase_to_gocs=mapray.GeoMath.createMatrix();mapray.GeoMath.iscs_to_gocs_matrix({longitude:this.longitude,latitude:this.latitude,height:this.height},base_to_gocs);returnbase_to_gocs;}// Generate a transformation matrix from the viewpoint coordinate system to the reference coordinate systemcreateViewToBaseMatrix(){constt=this.turn_angle*mapray.GeoMath.DEGREE;// turn angle (radian)constp=this.pitch_angle*mapray.GeoMath.DEGREE;// elevation/depression angle (radian)constd=this.distance;constsinT=Math.sin(t);constcosT=Math.cos(t);constsinP=Math.sin(p);constcosP=Math.cos(p);constmat=mapray.GeoMath.createMatrix();mat[0]=cosT;mat[1]=sinT;mat[2]=0;mat[3]=0;mat[4]=sinP*sinT;mat[5]=-sinP*cosT;mat[6]=cosP;mat[7]=0;mat[8]=sinT*cosP;mat[9]=-cosT*cosP;mat[10]=-sinP;mat[11]=0;mat[12]=d*sinT*cosP;mat[13]=-d*cosT*cosP;mat[14]=-d*sinP;mat[15]=1;returnmat;}}// Set up your apikey, which can be created in Mapray Cloud.constapikey="<YOUR_MAPRAY_API_KEY>";constviewer=newmapray.Viewer("mapray-container",{render_callback:newMyRenderCallback(),image_provider:newmapray.StandardImageProvider({url:"https://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/",format:"jpg",min_level:2,max_level:18,}),dem_provider:newmapray.CloudDemProvider(apikey)});</script>