more working
parent
7c97421dc2
commit
3ac96d180a
|
@ -1,3 +0,0 @@
|
|||
[submodule "src/survex"]
|
||||
path = src/survex
|
||||
url = git@github.com:ojwb/survex.git
|
BIN
src/Skydusky.3d
BIN
src/Skydusky.3d
Binary file not shown.
62
src/img.go
62
src/img.go
|
@ -6,17 +6,61 @@ package main
|
|||
*/
|
||||
import "C"
|
||||
import (
|
||||
"fmt"
|
||||
// "unsafe"
|
||||
// "encoding/json"
|
||||
// "fmt"
|
||||
)
|
||||
|
||||
func Test() {
|
||||
filename := C.CString("Skydusky.3d")
|
||||
pimg := C.img_open_survey(filename, nil)
|
||||
// for C.img_read_item(((*C.CStruct)(unsafe.Pointer(pimg))), ((*C.CStruct)(unsafe.Pointer((&pimg.mv))))) != C.img_BAD {
|
||||
for C.img_read_item(pimg, &pimg.mv) != C.img_BAD {
|
||||
if pimg.label != nil {
|
||||
fmt.Println(C.GoString(pimg.label))
|
||||
var pimg *C.img
|
||||
|
||||
type img struct {
|
||||
ImgReadCode int `json:"imgReadCode"`
|
||||
Title string `json:"title"`
|
||||
MvX float64 `json:"mv_x"`
|
||||
MvY float64 `json:"mv_y"`
|
||||
MvZ float64 `json:"mv_z"`
|
||||
}
|
||||
|
||||
func ImgOpen(filename string) interface{} {
|
||||
pimg = C.img_open_survey(C.CString(filename), nil)
|
||||
// fmt.Println(C.GoFloat64(pimg.mv.x))
|
||||
|
||||
if pimg.title == nil {
|
||||
return img{
|
||||
ImgReadCode: 0,
|
||||
Title: "NULL",
|
||||
MvX: float64(pimg.mv.x),
|
||||
MvY: float64(pimg.mv.y),
|
||||
MvZ: float64(pimg.mv.z),
|
||||
}
|
||||
} else {
|
||||
return img{
|
||||
ImgReadCode: 0,
|
||||
Title: C.GoString(pimg.title),
|
||||
MvX: float64(pimg.mv.x),
|
||||
MvY: float64(pimg.mv.y),
|
||||
MvZ: float64(pimg.mv.z),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ImgReadItem() img {
|
||||
img_read_code := C.img_read_item(pimg, &pimg.mv)
|
||||
|
||||
if pimg.title == nil {
|
||||
return img{
|
||||
ImgReadCode: int(img_read_code),
|
||||
Title: "NULL",
|
||||
MvX: float64(pimg.mv.x),
|
||||
MvY: float64(pimg.mv.y),
|
||||
MvZ: float64(pimg.mv.z),
|
||||
}
|
||||
} else {
|
||||
return img{
|
||||
ImgReadCode: int(img_read_code),
|
||||
Title: C.GoString(pimg.title),
|
||||
MvX: float64(pimg.mv.x),
|
||||
MvY: float64(pimg.mv.y),
|
||||
MvZ: float64(pimg.mv.z),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -17,7 +17,6 @@ var staticFiles embed.FS
|
|||
|
||||
func main() {
|
||||
log.SetFlags(log.Lshortfile)
|
||||
Test()
|
||||
|
||||
/* Web Server */
|
||||
http.Handle("/static/", http.FileServer(http.FS(staticFiles)))
|
||||
|
@ -38,6 +37,11 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
/* IMG */
|
||||
ui.Bind("img_open", ImgOpen)
|
||||
ui.Bind("img_read_item", ImgReadItem)
|
||||
|
||||
defer ui.Close()
|
||||
<-ui.Done()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
const canvas = document.getElementById("renderCanvas"); // Get the canvas element
|
||||
const engine = new BABYLON.Engine(canvas, true); // Generate the BABYLON 3D engine
|
||||
|
||||
// Add your code here matching the playground format
|
||||
const createScene = function () {
|
||||
|
||||
const scene = new BABYLON.Scene(engine);
|
||||
|
||||
BABYLON.SceneLoader.ImportMeshAsync("", "https://assets.babylonjs.com/meshes/", "box.babylon");
|
||||
|
||||
const camera = new BABYLON.ArcRotateCamera("camera", -Math.PI / 2, Math.PI / 2.5, 15, new BABYLON.Vector3(0, 0, 0));
|
||||
camera.attachControl(canvas, true);
|
||||
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(1, 1, 0));
|
||||
|
||||
return scene;
|
||||
};
|
||||
|
||||
|
||||
const scene = createScene(); //Call the createScene function
|
||||
|
||||
// Register a render loop to repeatedly render the scene
|
||||
engine.runRenderLoop(function () {
|
||||
scene.render();
|
||||
});
|
||||
|
||||
// Watch for browser/canvas resize events
|
||||
window.addEventListener("resize", function () {
|
||||
engine.resize();
|
||||
});
|
||||
|
||||
|
||||
/* IMG */
|
||||
let pimg = img_open('Skydusky.3d')
|
||||
pimg = img_read_item()
|
||||
pimg.then(o => console.log(o.label))
|
||||
pimg = img_read_item()
|
||||
pimg.then(o => console.log(o.label))
|
||||
pimg = img_read_item()
|
||||
pimg.then(o => console.log(o.label))
|
||||
pimg = img_read_item()
|
||||
pimg.then(o => console.log(o.label))
|
||||
pimg = img_read_item()
|
||||
pimg.then(o => console.log(o.label))
|
||||
pimg = img_read_item()
|
||||
pimg.then(o => console.log(o.label))
|
||||
pimg = img_read_item()
|
||||
pimg.then(o => console.log(o.label))
|
||||
pimg = img_read_item()
|
||||
pimg.then(o => console.log(o.label))
|
||||
pimg = img_read_item()
|
||||
pimg.then(o => console.log(o.label))
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 738af383b59aff8ffd2056a3228418f4d3201054
|
|
@ -8,37 +8,6 @@
|
|||
</head>
|
||||
<body>
|
||||
<canvas id="renderCanvas"></canvas>
|
||||
|
||||
<script>
|
||||
const canvas = document.getElementById("renderCanvas"); // Get the canvas element
|
||||
const engine = new BABYLON.Engine(canvas, true); // Generate the BABYLON 3D engine
|
||||
|
||||
// Add your code here matching the playground format
|
||||
const createScene = function () {
|
||||
|
||||
const scene = new BABYLON.Scene(engine);
|
||||
|
||||
BABYLON.SceneLoader.ImportMeshAsync("", "https://assets.babylonjs.com/meshes/", "box.babylon");
|
||||
|
||||
const camera = new BABYLON.ArcRotateCamera("camera", -Math.PI / 2, Math.PI / 2.5, 15, new BABYLON.Vector3(0, 0, 0));
|
||||
camera.attachControl(canvas, true);
|
||||
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(1, 1, 0));
|
||||
|
||||
return scene;
|
||||
};
|
||||
|
||||
|
||||
const scene = createScene(); //Call the createScene function
|
||||
|
||||
// Register a render loop to repeatedly render the scene
|
||||
engine.runRenderLoop(function () {
|
||||
scene.render();
|
||||
});
|
||||
|
||||
// Watch for browser/canvas resize events
|
||||
window.addEventListener("resize", function () {
|
||||
engine.resize();
|
||||
});
|
||||
</script>
|
||||
<script src="/static/kavea.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue