mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-08-11 17:09:01 +08:00
Add MetadataQuerier.GetIntEntryArray to JavaScript bindings (#521)
This commit is contained in:
parent
9fa96af9d1
commit
ad58758459
@ -40,6 +40,15 @@ long MetadataQuerier::GetIntEntry(const Metadata &metadata,
|
||||
return value;
|
||||
}
|
||||
|
||||
void MetadataQuerier::GetIntEntryArray(const draco::Metadata &metadata,
|
||||
const char *entry_name,
|
||||
DracoInt32Array *out_values) const {
|
||||
const std::string name(entry_name);
|
||||
std::vector<int32_t> values;
|
||||
metadata.GetEntryIntArray(name, &values);
|
||||
out_values->SetValues(values.data(), values.size());
|
||||
}
|
||||
|
||||
double MetadataQuerier::GetDoubleEntry(const Metadata &metadata,
|
||||
const char *entry_name) const {
|
||||
double value = 0;
|
||||
@ -298,9 +307,6 @@ void Decoder::SkipAttributeTransform(draco_GeometryAttribute_Type att_type) {
|
||||
}
|
||||
|
||||
const Metadata *Decoder::GetMetadata(const PointCloud &pc) const {
|
||||
if (!pc.GetMetadata()) {
|
||||
return nullptr;
|
||||
}
|
||||
return pc.GetMetadata();
|
||||
}
|
||||
|
||||
|
@ -31,39 +31,9 @@ typedef draco::EncodedGeometryType draco_EncodedGeometryType;
|
||||
typedef draco::Status draco_Status;
|
||||
typedef draco::Status::Code draco_StatusCode;
|
||||
|
||||
// To generate Draco JabvaScript bindings you must have emscripten installed.
|
||||
// To generate Draco JavaScript bindings you must have emscripten installed.
|
||||
// Then run make -f Makefile.emcc jslib.
|
||||
|
||||
class MetadataQuerier {
|
||||
public:
|
||||
MetadataQuerier();
|
||||
|
||||
bool HasEntry(const draco::Metadata &metadata, const char *entry_name) const;
|
||||
|
||||
// This function does not guarantee that entry's type is long.
|
||||
long GetIntEntry(const draco::Metadata &metadata,
|
||||
const char *entry_name) const;
|
||||
|
||||
// This function does not guarantee that entry's type is double.
|
||||
double GetDoubleEntry(const draco::Metadata &metadata,
|
||||
const char *entry_name) const;
|
||||
|
||||
// This function does not guarantee that entry's type is char*.
|
||||
const char *GetStringEntry(const draco::Metadata &metadata,
|
||||
const char *entry_name);
|
||||
|
||||
long NumEntries(const draco::Metadata &metadata) const;
|
||||
const char *GetEntryName(const draco::Metadata &metadata, int entry_id);
|
||||
|
||||
private:
|
||||
// Cached values for metadata entries.
|
||||
std::vector<std::string> entry_names_;
|
||||
const draco::Metadata *entry_names_metadata_;
|
||||
|
||||
// Cached value for GetStringEntry() to avoid scoping issues.
|
||||
std::string last_string_returned_;
|
||||
};
|
||||
|
||||
class DracoFloat32Array {
|
||||
public:
|
||||
DracoFloat32Array();
|
||||
@ -166,6 +136,40 @@ class DracoUInt32Array {
|
||||
std::vector<uint32_t> values_;
|
||||
};
|
||||
|
||||
class MetadataQuerier {
|
||||
public:
|
||||
MetadataQuerier();
|
||||
|
||||
bool HasEntry(const draco::Metadata &metadata, const char *entry_name) const;
|
||||
|
||||
// This function does not guarantee that entry's type is long.
|
||||
long GetIntEntry(const draco::Metadata &metadata,
|
||||
const char *entry_name) const;
|
||||
|
||||
// This function does not guarantee that entry types are long.
|
||||
void GetIntEntryArray(const draco::Metadata &metadata, const char *entry_name,
|
||||
DracoInt32Array *out_values) const;
|
||||
|
||||
// This function does not guarantee that entry's type is double.
|
||||
double GetDoubleEntry(const draco::Metadata &metadata,
|
||||
const char *entry_name) const;
|
||||
|
||||
// This function does not guarantee that entry's type is char*.
|
||||
const char *GetStringEntry(const draco::Metadata &metadata,
|
||||
const char *entry_name);
|
||||
|
||||
long NumEntries(const draco::Metadata &metadata) const;
|
||||
const char *GetEntryName(const draco::Metadata &metadata, int entry_id);
|
||||
|
||||
private:
|
||||
// Cached values for metadata entries.
|
||||
std::vector<std::string> entry_names_;
|
||||
const draco::Metadata *entry_names_metadata_;
|
||||
|
||||
// Cached value for GetStringEntry() to avoid scoping issues.
|
||||
std::string last_string_returned_;
|
||||
};
|
||||
|
||||
// Class used by emscripten WebIDL Binder [1] to wrap calls to decode Draco
|
||||
// data.
|
||||
// [1]http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/WebIDL-Binder.html
|
||||
|
@ -111,22 +111,6 @@ interface Status {
|
||||
[Const] DOMString error_msg();
|
||||
};
|
||||
|
||||
interface MetadataQuerier {
|
||||
void MetadataQuerier();
|
||||
|
||||
boolean HasEntry([Ref, Const] Metadata metadata,
|
||||
[Const] DOMString entry_name);
|
||||
long GetIntEntry([Ref, Const] Metadata metadata,
|
||||
[Const] DOMString entry_name);
|
||||
double GetDoubleEntry([Ref, Const] Metadata metadata,
|
||||
[Const] DOMString entry_name);
|
||||
[Const] DOMString GetStringEntry([Ref, Const] Metadata metadata,
|
||||
[Const] DOMString entry_name);
|
||||
|
||||
long NumEntries([Ref, Const] Metadata metadata);
|
||||
[Const] DOMString GetEntryName([Ref, Const] Metadata metadata, long entry_id);
|
||||
};
|
||||
|
||||
// Draco version of typed arrays. The memory of these arrays is allocated on the
|
||||
// emscripten heap.
|
||||
interface DracoFloat32Array {
|
||||
@ -171,6 +155,25 @@ interface DracoUInt32Array {
|
||||
long size();
|
||||
};
|
||||
|
||||
interface MetadataQuerier {
|
||||
void MetadataQuerier();
|
||||
|
||||
boolean HasEntry([Ref, Const] Metadata metadata,
|
||||
[Const] DOMString entry_name);
|
||||
long GetIntEntry([Ref, Const] Metadata metadata,
|
||||
[Const] DOMString entry_name);
|
||||
void GetIntEntryArray([Ref, Const] Metadata metadata,
|
||||
[Const] DOMString entry_name,
|
||||
DracoInt32Array out_values);
|
||||
double GetDoubleEntry([Ref, Const] Metadata metadata,
|
||||
[Const] DOMString entry_name);
|
||||
[Const] DOMString GetStringEntry([Ref, Const] Metadata metadata,
|
||||
[Const] DOMString entry_name);
|
||||
|
||||
long NumEntries([Ref, Const] Metadata metadata);
|
||||
[Const] DOMString GetEntryName([Ref, Const] Metadata metadata, long entry_id);
|
||||
};
|
||||
|
||||
interface Decoder {
|
||||
void Decoder();
|
||||
draco_EncodedGeometryType GetEncodedGeometryType(DecoderBuffer in_buffer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user