more working

master
Paul Walko 2021-09-19 19:55:44 -04:00
parent 7c97421dc2
commit 3ac96d180a
8 changed files with 110 additions and 46 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "src/survex"]
path = src/survex
url = git@github.com:ojwb/survex.git

Binary file not shown.

View File

@ -6,17 +6,61 @@ package main
*/ */
import "C" import "C"
import ( import (
"fmt" // "encoding/json"
// "unsafe" // "fmt"
) )
func Test() { var pimg *C.img
filename := C.CString("Skydusky.3d")
pimg := C.img_open_survey(filename, nil) type img struct {
// for C.img_read_item(((*C.CStruct)(unsafe.Pointer(pimg))), ((*C.CStruct)(unsafe.Pointer((&pimg.mv))))) != C.img_BAD { ImgReadCode int `json:"imgReadCode"`
for C.img_read_item(pimg, &pimg.mv) != C.img_BAD { Title string `json:"title"`
if pimg.label != nil { MvX float64 `json:"mv_x"`
fmt.Println(C.GoString(pimg.label)) 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.

View File

@ -17,7 +17,6 @@ var staticFiles embed.FS
func main() { func main() {
log.SetFlags(log.Lshortfile) log.SetFlags(log.Lshortfile)
Test()
/* Web Server */ /* Web Server */
http.Handle("/static/", http.FileServer(http.FS(staticFiles))) http.Handle("/static/", http.FileServer(http.FS(staticFiles)))
@ -38,6 +37,11 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
/* IMG */
ui.Bind("img_open", ImgOpen)
ui.Bind("img_read_item", ImgReadItem)
defer ui.Close() defer ui.Close()
<-ui.Done() <-ui.Done()
} }

51
src/static/kavea.js Normal file
View File

@ -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

View File

@ -8,37 +8,6 @@
</head> </head>
<body> <body>
<canvas id="renderCanvas"></canvas> <canvas id="renderCanvas"></canvas>
<script src="/static/kavea.js"></script>
<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>
</body> </body>
</html> </html>